json_encode not working with urldecode - php

json_encode not working with urldecode. Please give some solution
<?php
$decode_str = array();
$str = "%ED%A0%BD%ED%BA%97%D9%BE%D8%B1%D8%A7%DB%8C%D8%AF+89%D8%A8%D8%AF%D9%88%D9%86+%D8%B1%D9%86%DA%AF.+%D8%AA%DA%A9+%D8%B3%D9%88%D8%B2%ED%A0%BD%ED%BA%97";
$decode_str['output'] = urldecode($str);
echo json_encode($decode_str);
?>

If you add echo json_last_error_msg(); to the end of it, you will see that there is a json error.
Malformed UTF-8 characters, possibly incorrectly encoded
The string you are trying to encode has malformed UTF-8 Characters. You will need to fix the characted encoding before you can encode it into json.

Use utf8_decode() as well.
$decode_str = array();
$str = "%ED%A0%BD%ED%BA%97%D9%BE%D8%B1%D8%A7%DB%8C%D8%AF+89%D8%A8%D8%AF%D9%88%D9%86+%D8%B1%D9%86%DA%AF.+%D8%AA%DA%A9+%D8%B3%D9%88%D8%B2%ED%A0%BD%ED%BA%97";
$decode_str['output'] = utf8_decode(urldecode($str));
echo json_encode($decode_str);

Related

PHP Convert Unicode to text

I am receiving from a form the following urlencoded string %F0%9D%90%B4%F0%9D%91%99%F0%9D%91%92%F0%9D%91%97%F0%9D%91%8E%F0%9D%91%9B%F0%9D%91%91%F0%9D%91%9F%F0%9D%91%8E
If I decode it I get the following formatted text: ๐ด๐‘™๐‘’๐‘—๐‘Ž๐‘›๐‘‘๐‘Ÿ๐‘Ž
Is there any way with PHP to get the plain "Alejandra" text from the encoded or decoded string?
I have tried without success several ways to do it with
mb_convert_encoding($string, "UTF-16",mb_detect_encoding($string))
iconv('utf-16', 'utf-8', rawurldecode($string)
and any other solution I could in stackoverflow.
Edit:
I tried the proposed solution $strAscii = iconv('UTF-8','ASCII//TRANSLIT',$str); but it deletes the special characters such as รกรฉรญรณรบรฑรง which we need to stay.
Expected result
input: ๐ด๐‘™๐‘’๐‘—๐‘Ž๐‘›๐‘‘๐‘Ÿ๐‘Ž
output: Alejandra
input: รlejandra
output: รlejandra
Thank you in advance.
urldecode or rawurldecode is sufficient.
$string = "%F0%9D%90%B4%F0%9D%91%99%F0%9D%91%92%F0%9D%91%97%F0%9D%91%8E%F0%9D%91%9B%F0%9D%91%91%F0%9D%91%9F%F0%9D%91%8E";
$str = urldecode($string);
var_dump($str);
//string(36) "๐ด๐‘™๐‘’๐‘—๐‘Ž๐‘›๐‘‘๐‘Ÿ๐‘Ž"
Demo: https://3v4l.org/OMQ35
A special debugger gives me: string(36) UTF-8mb4. This means that there are also UTF-8 characters in the string that require 4 bytes. The character A is the Unicode character โ€œ๐ดโ€ (U+1D434).
Note:
If the special UTF-8 characters cause problems, you can try to display the strings as ASCII characters with iconv.
$strAscii = iconv('UTF-8','ASCII//TRANSLIT',$str);
//string(9) "Alejandra"
What you are getting is called a "psuedo-alphabet", you can see a list of them here: https://qaz.wtf/u/convert.cgi. The one that you appear to be getting can be seen here: https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols
Basically what you need to do is take the string, split it and use a lookup table to convert it back to regular characters. This implementation is terribly efficient but that's because I grabbed the alphabets from the above Wikipedia page and was too lazy to reorganise it.
function math_symbols_to_plain_text($input, $alphabet)
{
$alphabets = [
['a','๐š','๐‘Ž','๐’‚','๐–บ','๐—ฎ','๐˜ข','๐™–','๐’ถ','๐“ช','๐”ž','๐–†','๐šŠ','๐•’'],
['b','๐›','๐‘','๐’ƒ','๐–ป','๐—ฏ','๐˜ฃ','๐™—','๐’ท','๐“ซ','๐”Ÿ','๐–‡','๐š‹','๐•“'],
['c','๐œ','๐‘','๐’„','๐–ผ','๐—ฐ','๐˜ค','๐™˜','๐’ธ','๐“ฌ','๐” ','๐–ˆ','๐šŒ','๐•”'],
['d','๐','๐‘‘','๐’…','๐–ฝ','๐—ฑ','๐˜ฅ','๐™™','๐’น','๐“ญ','๐”ก','๐–‰','๐š','๐••'],
['e','๐ž','๐‘’','๐’†','๐–พ','๐—ฒ','๐˜ฆ','๐™š','โ„ฏ','๐“ฎ','๐”ข','๐–Š','๐šŽ','๐•–'],
['f','๐Ÿ','๐‘“','๐’‡','๐–ฟ','๐—ณ','๐˜ง','๐™›','๐’ป','๐“ฏ','๐”ฃ','๐–‹','๐š','๐•—'],
['g','๐ ','๐‘”','๐’ˆ','๐—€','๐—ด','๐˜จ','๐™œ','โ„Š','๐“ฐ','๐”ค','๐–Œ','๐š','๐•˜'],
['h','๐ก','โ„Ž','๐’‰','๐—','๐—ต','๐˜ฉ','๐™','๐’ฝ','๐“ฑ','๐”ฅ','๐–','๐š‘','๐•™'],
['i','๐ข','๐‘–','๐’Š','๐—‚','๐—ถ','๐˜ช','๐™ž','๐’พ','๐“ฒ','๐”ฆ','๐–Ž','๐š’','๐•š'],
['j','๐ฃ','๐‘—','๐’‹','๐—ƒ','๐—ท','๐˜ซ','๐™Ÿ','๐’ฟ','๐“ณ','๐”ง','๐–','๐š“','๐•›'],
['k','๐ค','๐‘˜','๐’Œ','๐—„','๐—ธ','๐˜ฌ','๐™ ','๐“€','๐“ด','๐”จ','๐–','๐š”','๐•œ'],
['l','๐ฅ','๐‘™','๐’','๐—…','๐—น','๐˜ญ','๐™ก','๐“','๐“ต','๐”ฉ','๐–‘','๐š•','๐•'],
['m','๐ฆ','๐‘š','๐’Ž','๐—†','๐—บ','๐˜ฎ','๐™ข','๐“‚','๐“ถ','๐”ช','๐–’','๐š–','๐•ž'],
['n','๐ง','๐‘›','๐’','๐—‡','๐—ป','๐˜ฏ','๐™ฃ','๐“ƒ','๐“ท','๐”ซ','๐–“','๐š—','๐•Ÿ'],
['o','๐จ','๐‘œ','๐’','๐—ˆ','๐—ผ','๐˜ฐ','๐™ค','โ„ด','๐“ธ','๐”ฌ','๐–”','๐š˜','๐• '],
['p','๐ฉ','๐‘','๐’‘','๐—‰','๐—ฝ','๐˜ฑ','๐™ฅ','๐“…','๐“น','๐”ญ','๐–•','๐š™','๐•ก'],
['q','๐ช','๐‘ž','๐’’','๐—Š','๐—พ','๐˜ฒ','๐™ฆ','๐“†','๐“บ','๐”ฎ','๐––','๐šš','๐•ข'],
['r','๐ซ','๐‘Ÿ','๐’“','๐—‹','๐—ฟ','๐˜ณ','๐™ง','๐“‡','๐“ป','๐”ฏ','๐–—','๐š›','๐•ฃ'],
['s','๐ฌ','๐‘ ','๐’”','๐—Œ','๐˜€','๐˜ด','๐™จ','๐“ˆ','๐“ผ','๐”ฐ','๐–˜','๐šœ','๐•ค'],
['t','๐ญ','๐‘ก','๐’•','๐—','๐˜','๐˜ต','๐™ฉ','๐“‰','๐“ฝ','๐”ฑ','๐–™','๐š','๐•ฅ'],
['u','๐ฎ','๐‘ข','๐’–','๐—Ž','๐˜‚','๐˜ถ','๐™ช','๐“Š','๐“พ','๐”ฒ','๐–š','๐šž','๐•ฆ'],
['v','๐ฏ','๐‘ฃ','๐’—','๐—','๐˜ƒ','๐˜ท','๐™ซ','๐“‹','๐“ฟ','๐”ณ','๐–›','๐šŸ','๐•ง'],
['w','๐ฐ','๐‘ค','๐’˜','๐—','๐˜„','๐˜ธ','๐™ฌ','๐“Œ','๐”€','๐”ด','๐–œ','๐š ','๐•จ'],
['x','๐ฑ','๐‘ฅ','๐’™','๐—‘','๐˜…','๐˜น','๐™ญ','๐“','๐”','๐”ต','๐–','๐šก','๐•ฉ'],
['y','๐ฒ','๐‘ฆ','๐’š','๐—’','๐˜†','๐˜บ','๐™ฎ','๐“Ž','๐”‚','๐”ถ','๐–ž','๐šข','๐•ช'],
['z','๐ณ','๐‘ง','๐’›','๐—“','๐˜‡','๐˜ป','๐™ฏ','๐“','๐”ƒ','๐”ท','๐–Ÿ','๐šฃ','๐•ซ'],
['A','๐€','๐ด','๐‘จ','๐– ','๐—”','๐˜ˆ','๐˜ผ','๐’œ','๐“','๐”„','๐•ฌ','๐™ฐ','๐”ธ'],
['B','๐','๐ต','๐‘ฉ','๐–ก','๐—•','๐˜‰','๐˜ฝ','โ„ฌ','๐“‘','๐”…','๐•ญ','๐™ฑ','๐”น'],
['C','๐‚','๐ถ','๐‘ช','๐–ข','๐—–','๐˜Š','๐˜พ','๐’ž','๐“’','โ„ญ','๐•ฎ','๐™ฒ','โ„‚'],
['D','๐ƒ','๐ท','๐‘ซ','๐–ฃ','๐——','๐˜‹','๐˜ฟ','๐’Ÿ','๐““','๐”‡','๐•ฏ','๐™ณ','๐”ป'],
['E','๐„','๐ธ','๐‘ฌ','๐–ค','๐—˜','๐˜Œ','๐™€','โ„ฐ','๐“”','๐”ˆ','๐•ฐ','๐™ด','๐”ผ'],
['F','๐…','๐น','๐‘ญ','๐–ฅ','๐—™','๐˜','๐™','โ„ฑ','๐“•','๐”‰','๐•ฑ','๐™ต','๐”ฝ'],
['G','๐†','๐บ','๐‘ฎ','๐–ฆ','๐—š','๐˜Ž','๐™‚','๐’ข','๐“–','๐”Š','๐•ฒ','๐™ถ','๐”พ'],
['H','๐‡','๐ป','๐‘ฏ','๐–ง','๐—›','๐˜','๐™ƒ','โ„‹','๐“—','โ„Œ','๐•ณ','๐™ท','โ„'],
['I','๐ˆ','๐ผ','๐‘ฐ','๐–จ','๐—œ','๐˜','๐™„','โ„','๐“˜','โ„‘','๐•ด','๐™ธ','๐•€'],
['J','๐‰','๐ฝ','๐‘ฑ','๐–ฉ','๐—','๐˜‘','๐™…','๐’ฅ','๐“™','๐”','๐•ต','๐™น','๐•'],
['K','๐Š','๐พ','๐‘ฒ','๐–ช','๐—ž','๐˜’','๐™†','๐’ฆ','๐“š','๐”Ž','๐•ถ','๐™บ','๐•‚'],
['L','๐‹','๐ฟ','๐‘ณ','๐–ซ','๐—Ÿ','๐˜“','๐™‡','โ„’','๐“›','๐”','๐•ท','๐™ป','๐•ƒ'],
['M','๐Œ','๐‘€','๐‘ด','๐–ฌ','๐— ','๐˜”','๐™ˆ','โ„ณ','๐“œ','๐”','๐•ธ','๐™ผ','๐•„'],
['N','๐','๐‘','๐‘ต','๐–ญ','๐—ก','๐˜•','๐™‰','๐’ฉ','๐“','๐”‘','๐•น','๐™ฝ','โ„•'],
['O','๐Ž','๐‘‚','๐‘ถ','๐–ฎ','๐—ข','๐˜–','๐™Š','๐’ช','๐“ž','๐”’','๐•บ','๐™พ','๐•†'],
['P','๐','๐‘ƒ','๐‘ท','๐–ฏ','๐—ฃ','๐˜—','๐™‹','๐’ซ','๐“Ÿ','๐”“','๐•ป','๐™ฟ','โ„™'],
['Q','๐','๐‘„','๐‘ธ','๐–ฐ','๐—ค','๐˜˜','๐™Œ','๐’ฌ','๐“ ','๐””','๐•ผ','๐š€','โ„š'],
['R','๐‘','๐‘…','๐‘น','๐–ฑ','๐—ฅ','๐˜™','๐™','โ„›','๐“ก','โ„œ','๐•ฝ','๐š','โ„'],
['S','๐’','๐‘†','๐‘บ','๐–ฒ','๐—ฆ','๐˜š','๐™Ž','๐’ฎ','๐“ข','๐”–','๐•พ','๐š‚','๐•Š'],
['T','๐“','๐‘‡','๐‘ป','๐–ณ','๐—ง','๐˜›','๐™','๐’ฏ','๐“ฃ','๐”—','๐•ฟ','๐šƒ','๐•‹'],
['U','๐”','๐‘ˆ','๐‘ผ','๐–ด','๐—จ','๐˜œ','๐™','๐’ฐ','๐“ค','๐”˜','๐–€','๐š„','๐•Œ'],
['V','๐•','๐‘‰','๐‘ฝ','๐–ต','๐—ฉ','๐˜','๐™‘','๐’ฑ','๐“ฅ','๐”™','๐–','๐š…','๐•'],
['W','๐–','๐‘Š','๐‘พ','๐–ถ','๐—ช','๐˜ž','๐™’','๐’ฒ','๐“ฆ','๐”š','๐–‚','๐š†','๐•Ž'],
['X','๐—','๐‘‹','๐‘ฟ','๐–ท','๐—ซ','๐˜Ÿ','๐™“','๐’ณ','๐“ง','๐”›','๐–ƒ','๐š‡','๐•'],
['Y','๐˜','๐‘Œ','๐’€','๐–ธ','๐—ฌ','๐˜ ','๐™”','๐’ด','๐“จ','๐”œ','๐–„','๐šˆ','๐•'],
['Z','๐™','๐‘','๐’','๐–น','๐—ญ','๐˜ก','๐™•','๐’ต','๐“ฉ','โ„จ','๐–…','๐š‰','โ„ค']
];
$replace = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
$lookup = [
'serif-normal',
'serif-bold',
'serif-italic',
'serif-bolditalic',
'sans-normal',
'sans-bold',
'sans-italic',
'sans-bolditalic',
'script-normal',
'script-bold',
'franktur-normal',
'fraktur-bold',
'monospace',
'doublestruck'
];
$map_index = array_search($alphabet, $lookup);
$split = mb_str_split($input);
$output = '';
foreach ($split as $char) {
foreach ($alphabets as $i => $letter) {
if ($letter[$map_index] === $char)
$output .= $replace[$i];
}
}
return $output;
}
$input = '๐ด๐‘™๐‘’๐‘—๐‘Ž๐‘›๐‘‘๐‘Ÿ๐‘Ž';
$output = math_symbols_to_plain_text($input, 'serif-italic');
echo $input . PHP_EOL . $output . PHP_EOL;
Yields:
๐ด๐‘™๐‘’๐‘—๐‘Ž๐‘›๐‘‘๐‘Ÿ๐‘Ž
Alejandra
If I am not wrong, you are trying to decode URL then why you are not trying to use urldecode()
follow this .PHP DOC

Decode string with \x in PHP that has char encoded over 255

My problem is about string decoding.
Let's assume a string like:
$str = "\xce\xbb\xc6\x9b\xc2\xac\xe2\x88\xa7\xe2\x9f\x91\xe2\x88\xa8\xe2\x9f\x87\xc3\xb7 \xe2\x82\xac\xc2\xbd\xe2\x88\x86\xc3\xb8\xe2\x86\x94\xc2\xa2\xe2\x8c\x90\xc3\xa6";
I want to decode it and to look like that:
ฮปฦ›ยฌโˆงโŸ‘โˆจโŸ‡รท โ‚ฌยฝโˆ†รธโ†”ยขโŒรฆ
I tried to use
utf8_encode(utf8_encode($str));
But it's not what was expected.
In python something like that works:
_str = b"\xce\xbb\xc6\x9b\xc2\xac\xe2\x88\xa7\xe2\x9f\x91\xe2\x88\xa8\xe2\x9f\x87\xc3\xb7 \xe2\x82\xac\xc2\xbd\xe2\x88\x86\xc3\xb8\xe2\x86\x94\xc2\xa2\xe2\x8c\x90\xc3\xa6"
_str = _str.decode()
print(_str)
You don't need to decode that. This is legal notation for strings in PHP.
$str = "\xce\xbb\xc6\x9b\xc2\xac\xe2\x88\xa7\xe2\x9f\x91\xe2\x88\xa8\xe2\x9f\x87\xc3\xb7 \xe2\x82\xac\xc2\xbd\xe2\x88\x86\xc3\xb8\xe2\x86\x94\xc2\xa2\xe2\x8c\x90\xc3\xa6";
echo $str; //ฮปฦ›ยฌโˆงโŸ‘โˆจโŸ‡รท โ‚ฌยฝโˆ†รธโ†”ยขโŒรฆ
https://3v4l.org/0e0Po

Decode string php

I am trying to decode a string in PHP but I have not idea what the encoding is.
My string is
\x5B\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20d\x27Asni\x5Cu00e8res\x20sur\x20Seine\x20Belfort\x22,\x22id\x22\x3A\x225337\x22,\x22lati\x22\x3A\x2248.907864\x22,\x22long\x22\x3A\x222.268167\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20d\x27Asni\x5Cu00e8res\x20sur\x20Seine\x20Les\x20Hauts\x20d\x27Asni\x5Cu00e8res\x22,\x22id\x22\x3A\x225338\x22,\x22lati\x22\x3A\x2248.925983\x22,\x22long\x22\x3A\x222.274256\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Bagneux\x20Port\x20Galand\x22,\x22id\x22\x3A\x225339\x22,\x22lati\x22\x3A\x2248.788372\x22,\x22long\x22\x3A\x222.317539\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Bois\x20Colombes\x20Les\x20Bruy\x5Cu00e8res\x22,\x22id\x22\x3A\x225340\x22,\x22lati\x22\x3A\x2248.908581\x22,\x22long\x22\x3A\x222.262088\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Colombes\x20Foss\x5Cu00e9\x20Jean\x22,\x22id\x22\x3A\x225342\x22,\x22lati\x22\x3A\x2248.93106\x22,\x22long\x22\x3A\x222.267059\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Colombes\x20Wiener\x22,\x22id\x22\x3A\x225343\x22,\x22lati\x22\x3A\x2248.915141\x22,\x22long\x22\x3A\x222.246733\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Courbevoie\x20\x2D\x20Quartier\x20de\x20B\x5Cu00e9con\x22,\x22id\x22\x3A\x225344\x22,\x22lati\x22\x3A\x2248.901328\x22,\x22long\x22\x3A\x222.265769\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Courbevoie\x20\x2D\x20Quartier\x20Faubourg\x20de\x20l\x27Arche\x22,\x22id\x22\x3A\x225345\x22,\x22lati\x22\x3A\x2248.897737\x22,\x22long\x22\x3A\x222.238265\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20Meudon\x20la\x20For\x5Cu00eat\x20Place\x20Centrale\x22,\x22id\x22\x3A\x225346\x22,\x22lati\x22\x3A\x2248.787749\x22,\x22long\x22\x3A\x222.227974\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2010\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224463\x22,\x22lati\x22\x3A\x2248.871982\x22,\x22long\x22\x3A\x222.357889\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2012\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224464\x22,\x22lati\x22\x3A\x2248.840246\x22,\x22long\x22\x3A\x222.388204\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2014\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224465\x22,\x22lati\x22\x3A\x2248.832864\x22,\x22long\x22\x3A\x222.326462\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2015\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224475\x22,\x22lati\x22\x3A\x2248.841647\x22,\x22long\x22\x3A\x222.299668\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2016\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224466\x22,\x22lati\x22\x3A\x2248.863973\x22,\x22long\x22\x3A\x222.277212\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2017\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224467\x22,\x22lati\x22\x3A\x2248.883034\x22,\x22long\x22\x3A\x222.32408\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2018\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224468\x22,\x22lati\x22\x3A\x2248.892666\x22,\x22long\x22\x3A\x222.337346\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2019\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224461\x22,\x22lati\x22\x3A\x2248.876334\x22,\x22long\x22\x3A\x222.39318\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2020\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224469\x22,\x22lati\x22\x3A\x2248.864976\x22,\x22long\x22\x3A\x222.39871\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x205\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224471\x22,\x22lati\x22\x3A\x2248.846319\x22,\x22long\x22\x3A\x222.344516\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x207\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224472\x22,\x22lati\x22\x3A\x2248.856888\x22,\x22long\x22\x3A\x222.319964\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x208\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224473\x22,\x22lati\x22\x3A\x2248.877862\x22,\x22long\x22\x3A\x222.317804\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x209\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224474\x22,\x22lati\x22\x3A\x2248.872497\x22,\x22long\x22\x3A\x222.340366\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20d\x27ALFORTVILLE\x22,\x22id\x22\x3A\x225392\x22,\x22lati\x22\x3A\x2248.80529\x22,\x22long\x22\x3A\x222.420021\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20d\x27ARCUEIL\x22,\x22id\x22\x3A\x225032\x22,\x22lati\x22\x3A\x2248.805973\x22,\x22long\x22\x3A\x222.336826\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20ASNIERES\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224799\x22,\x22lati\x22\x3A\x2248.910354\x22,\x22long\x22\x3A\x222.289417\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20AUBERVILLIERS\x22,\x22id\x22\x3A\x224825\x22,\x22lati\x22\x3A\x2248.914652\x22,\x22long\x22\x3A\x222.381673\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BAGNEUX\x22,\x22id\x22\x3A\x224800\x22,\x22lati\x22\x3A\x2248.798652\x22,\x22long\x22\x3A\x222.304296\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BAGNOLET\x22,\x22id\x22\x3A\x224827\x22,\x22lati\x22\x3A\x2248.868921\x22,\x22long\x22\x3A\x222.417979\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BOIS\x20COLOMBES\x22,\x22id\x22\x3A\x224824\x22,\x22lati\x22\x3A\x2248.914476\x22,\x22long\x22\x3A\x222.267797\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BOULOGNE\x20BILLANCOURT\x22,\x22id\x22\x3A\x224801\x22,\x22lati\x22\x3A\x2248.835388\x22,\x22long\x22\x3A\x222.24031\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CACHAN\x22,\x22id\x22\x3A\x224859\x22,\x22lati\x22\x3A\x2248.794443\x22,\x22long\x22\x3A\x222.331244\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHARENTON\x20LE\x20PONT\x22,\x22id\x22\x3A\x225395\x22,\x22lati\x22\x3A\x2248.819851\x22,\x22long\x22\x3A\x222.415667\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATENAY\x20MALABRY\x22,\x22id\x22\x3A\x224802\x22,\x22lati\x22\x3A\x2248.767087\x22,\x22long\x22\x3A\x222.277421\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATILLON\x22,\x22id\x22\x3A\x225382\x22,\x22lati\x22\x3A\x2248.799868\x22,\x22long\x22\x3A\x222.289823\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATOU\x22,\x22id\x22\x3A\x224531\x22,\x22lati\x22\x3A\x2248.890074\x22,\x22long\x22\x3A\x222.157537\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHOISY\x20LE\x20ROI\x22,\x22id\x22\x3A\x224861\x22,\x22lati\x22\x3A\x2248.762448\x22,\x22long\x22\x3A\x222.406938\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CLAMART\x22,\x22id\x22\x3A\x224803\x22,\x22lati\x22\x3A\x2248.800313\x22,\x22long\x22\x3A\x222.263162\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CLICHY\x22,\x22id\x22\x3A\x224804\x22,\x22lati\x22\x3A\x2248.902389\x22,\x22long\x22\x3A\x222.304312\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20COLOMBES\x22,\x22id\x22\x3A\x224805\x22,\x22lati\x22\x3A\x2248.92276\x22,\x22long\x22\x3A\x222.254343\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20COURBEVOIE\x22,\x22id\x22\x3A\x224806\x22,\x22lati\x22\x3A\x2248.895463\x22,\x22long\x22\x3A\x222.2565\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20DRANCY\x22,\x22id\x22\x3A\x224831\x22,\x22lati\x22\x3A\x2248.925691\x22,\x22long\x22\x3A\x222.389513\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20FRESNES\x22,\x22id\x22\x3A\x225398\x22,\x22lati\x22\x3A\x2248.75534\x22,\x22long\x22\x3A\x222.322471\x22\x7D,\x7B\x22name\x22\x3A\x22mairie\x20de\x20Garches\x22,\x22id\x22\x3A\x225287\x22,\x22lati\x22\x3A\x2248.843147\x22,\x22long\x22\x3A\x222.186586\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20GENNEVILLIERS\x22,\x22id\x22\x3A\x224807\x22,\x22lati\x22\x3A\x2248.925846\x22,\x22long\x22\x3A\x222.294367\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20HOUILLES\x22,\x22id\x22\x3A\x224535\x22,\x22lati\x22\x3A\x2248.923084\x22,\x22long\x22\x3A\x222.186666\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20ISSY\x20LES\x20MOULINEAUX\x22,\x22id\x22\x3A\x224808\x22,\x22lati\x22\x3A\x2248.82423\x22,\x22long\x22\x3A\x222.273643\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20IVRY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224864\x22,\x22lati\x22\x3A\x2248.807809\x22,\x22long\x22\x3A\x222.374647\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20L\x27HAY\x20LES\x20ROSES\x22,\x22id\x22\x3A\x224868\x22,\x22lati\x22\x3A\x2248.778867\x22,\x22long\x22\x3A\x222.337234\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LA\x20COURNEUVE\x22,\x22id\x22\x3A\x224835\x22,\x22lati\x22\x3A\x2248.926341\x22,\x22long\x22\x3A\x222.391157\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LA\x20GARENNE\x20COLOMBES\x22,\x22id\x22\x3A\x224809\x22,\x22lati\x22\x3A\x2248.906762\x22,\x22long\x22\x3A\x222.246125\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20BOURGET\x22,\x22id\x22\x3A\x224837\x22,\x22lati\x22\x3A\x2248.934871\x22,\x22long\x22\x3A\x222.425765\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20PLESSIS\x20ROBINSON\x22,\x22id\x22\x3A\x224823\x22,\x22lati\x22\x3A\x2248.78248\x22,\x22long\x22\x3A\x222.262036\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20PRE\x20SAINT\x20GERVAIS\x22,\x22id\x22\x3A\x224838\x22,\x22lati\x22\x3A\x2248.883069\x22,\x22long\x22\x3A\x222.403281\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LES\x20LILAS\x22,\x22id\x22\x3A\x224840\x22,\x22lati\x22\x3A\x2248.880519\x22,\x22long\x22\x3A\x222.41849\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LEVALLOIS\x22,\x22id\x22\x3A\x224810\x22,\x22lati\x22\x3A\x2248.893086\x22,\x22long\x22\x3A\x222.288514\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MALAKOFF\x22,\x22id\x22\x3A\x224811\x22,\x22lati\x22\x3A\x2248.820888\x22,\x22long\x22\x3A\x222.301668\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MEUDON\x22,\x22id\x22\x3A\x224812\x22,\x22lati\x22\x3A\x2248.812558\x22,\x22long\x22\x3A\x222.238593\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MONTROUGE\x22,\x22id\x22\x3A\x224813\x22,\x22lati\x22\x3A\x2248.818705\x22,\x22long\x22\x3A\x222.319896\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20NANTERRE\x22,\x22id\x22\x3A\x224814\x22,\x22lati\x22\x3A\x2248.892044\x22,\x22long\x22\x3A\x222.205266\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20NEUILLY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224815\x22,\x22lati\x22\x3A\x2248.885111\x22,\x22long\x22\x3A\x222.266186\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20PANTIN\x22,\x22id\x22\x3A\x224845\x22,\x22lati\x22\x3A\x2248.896479\x22,\x22long\x22\x3A\x222.401907\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20PUTEAUX\x22,\x22id\x22\x3A\x224816\x22,\x22lati\x22\x3A\x2248.8843\x22,\x22long\x22\x3A\x222.236835\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20RUEIL\x20MALMAISON\x22,\x22id\x22\x3A\x224817\x22,\x22lati\x22\x3A\x2248.877939\x22,\x22long\x22\x3A\x222.180679\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20CLOUD\x22,\x22id\x22\x3A\x224818\x22,\x22lati\x22\x3A\x2248.843706\x22,\x22long\x22\x3A\x222.219356\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x2DDENIS\x22,\x22id\x22\x3A\x224851\x22,\x22lati\x22\x3A\x2248.936005\x22,\x22long\x22\x3A\x222.358906\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20MANDE\x22,\x22id\x22\x3A\x225407\x22,\x22lati\x22\x3A\x2248.843501\x22,\x22long\x22\x3A\x222.419041\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20MAURICE\x22,\x22id\x22\x3A\x224873\x22,\x22lati\x22\x3A\x2248.818091\x22,\x22long\x22\x3A\x222.423183\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20OUEN\x22,\x22id\x22\x3A\x224850\x22,\x22lati\x22\x3A\x2248.912188\x22,\x22long\x22\x3A\x222.333285\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SCEAUX\x22,\x22id\x22\x3A\x224819\x22,\x22lati\x22\x3A\x2248.778775\x22,\x22long\x22\x3A\x222.288772\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SEVRES\x22,\x22id\x22\x3A\x224820\x22,\x22lati\x22\x3A\x2248.824434\x22,\x22long\x22\x3A\x222.21308\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SURESNES\x22,\x22id\x22\x3A\x224821\x22,\x22lati\x22\x3A\x2248.87113\x22,\x22long\x22\x3A\x222.224667\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20THIAIS\x22,\x22id\x22\x3A\x224875\x22,\x22lati\x22\x3A\x2248.765315\x22,\x22long\x22\x3A\x222.388829\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VANVES\x22,\x22id\x22\x3A\x224822\x22,\x22lati\x22\x3A\x2248.821396\x22,\x22long\x22\x3A\x222.289619\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VELIZY\x20VILLACOUBLAY\x22,\x22id\x22\x3A\x224558\x22,\x22lati\x22\x3A\x2248.782531\x22,\x22long\x22\x3A\x222.191265\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VILLEJUIF\x22,\x22id\x22\x3A\x224876\x22,\x22lati\x22\x3A\x2248.794931\x22,\x22long\x22\x3A\x222.366248\x22\x7D,\x7B\x22name\x22\x3A\x22mairie\x20de\x20Villeneuve\x2Dla\x2DGarenne\x22,\x22id\x22\x3A\x223990\x22,\x22lati\x22\x3A\x2248.935596\x22,\x22long\x22\x3A\x222.332934\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VIROFLAY\x22,\x22id\x22\x3A\x224559\x22,\x22lati\x22\x3A\x2248.799422\x22,\x22long\x22\x3A\x222.172793\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VITRY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224878\x22,\x22lati\x22\x3A\x2248.788757\x22,\x22long\x22\x3A\x222.38929\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20LE\x20KREMLIN\x20BICETRE\x22,\x22id\x22\x3A\x225400\x22,\x22lati\x22\x3A\x2248.812652\x22,\x22long\x22\x3A\x222.356646\x22\x7D,\x7B\x22name\x22\x3A\x22Pr\x5Cu00e9fecture\x20de\x20Police\x20\x20\x2D\x20Site\x20de\x20Gesvres\x204\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224470\x22,\x22lati\x22\x3A\x2248.856894\x22,\x22long\x22\x3A\x222.348783\x22\x7D\x5D
I tried json_decode($myString) but it doesn't works
it works in javascript JSON.parse(...)
This is a JSON alright but in hex so converting from hex to string and should output to browser as JSON
<?php
header('Content-type: application/json');
function decode_code($code){
return preg_replace_callback(
"#\\\(x)?([0-9a-f]{2,3})#",
function($m){
return chr($m[1]?hexdec($m[2]):octdec($m[2]));
},
$code
);
}
echo (decode_code("\x5B\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20d\x27Asni\x5Cu00e8res\x20sur\x20Seine\x20Belfort\x22,\x22id\x22\x3A\x225337\x22,\x22lati\x22\x3A\x2248.907864\x22,\x22long\x22\x3A\x222.268167\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20d\x27Asni\x5Cu00e8res\x20sur\x20Seine\x20Les\x20Hauts\x20d\x27Asni\x5Cu00e8res\x22,\x22id\x22\x3A\x225338\x22,\x22lati\x22\x3A\x2248.925983\x22,\x22long\x22\x3A\x222.274256\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Bagneux\x20Port\x20Galand\x22,\x22id\x22\x3A\x225339\x22,\x22lati\x22\x3A\x2248.788372\x22,\x22long\x22\x3A\x222.317539\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Bois\x20Colombes\x20Les\x20Bruy\x5Cu00e8res\x22,\x22id\x22\x3A\x225340\x22,\x22lati\x22\x3A\x2248.908581\x22,\x22long\x22\x3A\x222.262088\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Colombes\x20Foss\x5Cu00e9\x20Jean\x22,\x22id\x22\x3A\x225342\x22,\x22lati\x22\x3A\x2248.93106\x22,\x22long\x22\x3A\x222.267059\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Colombes\x20Wiener\x22,\x22id\x22\x3A\x225343\x22,\x22lati\x22\x3A\x2248.915141\x22,\x22long\x22\x3A\x222.246733\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Courbevoie\x20\x2D\x20Quartier\x20de\x20B\x5Cu00e9con\x22,\x22id\x22\x3A\x225344\x22,\x22lati\x22\x3A\x2248.901328\x22,\x22long\x22\x3A\x222.265769\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Courbevoie\x20\x2D\x20Quartier\x20Faubourg\x20de\x20l\x27Arche\x22,\x22id\x22\x3A\x225345\x22,\x22lati\x22\x3A\x2248.897737\x22,\x22long\x22\x3A\x222.238265\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20Meudon\x20la\x20For\x5Cu00eat\x20Place\x20Centrale\x22,\x22id\x22\x3A\x225346\x22,\x22lati\x22\x3A\x2248.787749\x22,\x22long\x22\x3A\x222.227974\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2010\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224463\x22,\x22lati\x22\x3A\x2248.871982\x22,\x22long\x22\x3A\x222.357889\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2012\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224464\x22,\x22lati\x22\x3A\x2248.840246\x22,\x22long\x22\x3A\x222.388204\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2014\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224465\x22,\x22lati\x22\x3A\x2248.832864\x22,\x22long\x22\x3A\x222.326462\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2015\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224475\x22,\x22lati\x22\x3A\x2248.841647\x22,\x22long\x22\x3A\x222.299668\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2016\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224466\x22,\x22lati\x22\x3A\x2248.863973\x22,\x22long\x22\x3A\x222.277212\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2017\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224467\x22,\x22lati\x22\x3A\x2248.883034\x22,\x22long\x22\x3A\x222.32408\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2018\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224468\x22,\x22lati\x22\x3A\x2248.892666\x22,\x22long\x22\x3A\x222.337346\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2019\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224461\x22,\x22lati\x22\x3A\x2248.876334\x22,\x22long\x22\x3A\x222.39318\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2020\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224469\x22,\x22lati\x22\x3A\x2248.864976\x22,\x22long\x22\x3A\x222.39871\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x205\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224471\x22,\x22lati\x22\x3A\x2248.846319\x22,\x22long\x22\x3A\x222.344516\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x207\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224472\x22,\x22lati\x22\x3A\x2248.856888\x22,\x22long\x22\x3A\x222.319964\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x208\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224473\x22,\x22lati\x22\x3A\x2248.877862\x22,\x22long\x22\x3A\x222.317804\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x209\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224474\x22,\x22lati\x22\x3A\x2248.872497\x22,\x22long\x22\x3A\x222.340366\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20d\x27ALFORTVILLE\x22,\x22id\x22\x3A\x225392\x22,\x22lati\x22\x3A\x2248.80529\x22,\x22long\x22\x3A\x222.420021\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20d\x27ARCUEIL\x22,\x22id\x22\x3A\x225032\x22,\x22lati\x22\x3A\x2248.805973\x22,\x22long\x22\x3A\x222.336826\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20ASNIERES\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224799\x22,\x22lati\x22\x3A\x2248.910354\x22,\x22long\x22\x3A\x222.289417\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20AUBERVILLIERS\x22,\x22id\x22\x3A\x224825\x22,\x22lati\x22\x3A\x2248.914652\x22,\x22long\x22\x3A\x222.381673\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BAGNEUX\x22,\x22id\x22\x3A\x224800\x22,\x22lati\x22\x3A\x2248.798652\x22,\x22long\x22\x3A\x222.304296\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BAGNOLET\x22,\x22id\x22\x3A\x224827\x22,\x22lati\x22\x3A\x2248.868921\x22,\x22long\x22\x3A\x222.417979\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BOIS\x20COLOMBES\x22,\x22id\x22\x3A\x224824\x22,\x22lati\x22\x3A\x2248.914476\x22,\x22long\x22\x3A\x222.267797\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BOULOGNE\x20BILLANCOURT\x22,\x22id\x22\x3A\x224801\x22,\x22lati\x22\x3A\x2248.835388\x22,\x22long\x22\x3A\x222.24031\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CACHAN\x22,\x22id\x22\x3A\x224859\x22,\x22lati\x22\x3A\x2248.794443\x22,\x22long\x22\x3A\x222.331244\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHARENTON\x20LE\x20PONT\x22,\x22id\x22\x3A\x225395\x22,\x22lati\x22\x3A\x2248.819851\x22,\x22long\x22\x3A\x222.415667\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATENAY\x20MALABRY\x22,\x22id\x22\x3A\x224802\x22,\x22lati\x22\x3A\x2248.767087\x22,\x22long\x22\x3A\x222.277421\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATILLON\x22,\x22id\x22\x3A\x225382\x22,\x22lati\x22\x3A\x2248.799868\x22,\x22long\x22\x3A\x222.289823\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATOU\x22,\x22id\x22\x3A\x224531\x22,\x22lati\x22\x3A\x2248.890074\x22,\x22long\x22\x3A\x222.157537\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHOISY\x20LE\x20ROI\x22,\x22id\x22\x3A\x224861\x22,\x22lati\x22\x3A\x2248.762448\x22,\x22long\x22\x3A\x222.406938\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CLAMART\x22,\x22id\x22\x3A\x224803\x22,\x22lati\x22\x3A\x2248.800313\x22,\x22long\x22\x3A\x222.263162\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CLICHY\x22,\x22id\x22\x3A\x224804\x22,\x22lati\x22\x3A\x2248.902389\x22,\x22long\x22\x3A\x222.304312\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20COLOMBES\x22,\x22id\x22\x3A\x224805\x22,\x22lati\x22\x3A\x2248.92276\x22,\x22long\x22\x3A\x222.254343\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20COURBEVOIE\x22,\x22id\x22\x3A\x224806\x22,\x22lati\x22\x3A\x2248.895463\x22,\x22long\x22\x3A\x222.2565\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20DRANCY\x22,\x22id\x22\x3A\x224831\x22,\x22lati\x22\x3A\x2248.925691\x22,\x22long\x22\x3A\x222.389513\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20FRESNES\x22,\x22id\x22\x3A\x225398\x22,\x22lati\x22\x3A\x2248.75534\x22,\x22long\x22\x3A\x222.322471\x22\x7D,\x7B\x22name\x22\x3A\x22mairie\x20de\x20Garches\x22,\x22id\x22\x3A\x225287\x22,\x22lati\x22\x3A\x2248.843147\x22,\x22long\x22\x3A\x222.186586\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20GENNEVILLIERS\x22,\x22id\x22\x3A\x224807\x22,\x22lati\x22\x3A\x2248.925846\x22,\x22long\x22\x3A\x222.294367\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20HOUILLES\x22,\x22id\x22\x3A\x224535\x22,\x22lati\x22\x3A\x2248.923084\x22,\x22long\x22\x3A\x222.186666\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20ISSY\x20LES\x20MOULINEAUX\x22,\x22id\x22\x3A\x224808\x22,\x22lati\x22\x3A\x2248.82423\x22,\x22long\x22\x3A\x222.273643\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20IVRY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224864\x22,\x22lati\x22\x3A\x2248.807809\x22,\x22long\x22\x3A\x222.374647\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20L\x27HAY\x20LES\x20ROSES\x22,\x22id\x22\x3A\x224868\x22,\x22lati\x22\x3A\x2248.778867\x22,\x22long\x22\x3A\x222.337234\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LA\x20COURNEUVE\x22,\x22id\x22\x3A\x224835\x22,\x22lati\x22\x3A\x2248.926341\x22,\x22long\x22\x3A\x222.391157\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LA\x20GARENNE\x20COLOMBES\x22,\x22id\x22\x3A\x224809\x22,\x22lati\x22\x3A\x2248.906762\x22,\x22long\x22\x3A\x222.246125\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20BOURGET\x22,\x22id\x22\x3A\x224837\x22,\x22lati\x22\x3A\x2248.934871\x22,\x22long\x22\x3A\x222.425765\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20PLESSIS\x20ROBINSON\x22,\x22id\x22\x3A\x224823\x22,\x22lati\x22\x3A\x2248.78248\x22,\x22long\x22\x3A\x222.262036\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20PRE\x20SAINT\x20GERVAIS\x22,\x22id\x22\x3A\x224838\x22,\x22lati\x22\x3A\x2248.883069\x22,\x22long\x22\x3A\x222.403281\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LES\x20LILAS\x22,\x22id\x22\x3A\x224840\x22,\x22lati\x22\x3A\x2248.880519\x22,\x22long\x22\x3A\x222.41849\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LEVALLOIS\x22,\x22id\x22\x3A\x224810\x22,\x22lati\x22\x3A\x2248.893086\x22,\x22long\x22\x3A\x222.288514\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MALAKOFF\x22,\x22id\x22\x3A\x224811\x22,\x22lati\x22\x3A\x2248.820888\x22,\x22long\x22\x3A\x222.301668\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MEUDON\x22,\x22id\x22\x3A\x224812\x22,\x22lati\x22\x3A\x2248.812558\x22,\x22long\x22\x3A\x222.238593\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MONTROUGE\x22,\x22id\x22\x3A\x224813\x22,\x22lati\x22\x3A\x2248.818705\x22,\x22long\x22\x3A\x222.319896\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20NANTERRE\x22,\x22id\x22\x3A\x224814\x22,\x22lati\x22\x3A\x2248.892044\x22,\x22long\x22\x3A\x222.205266\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20NEUILLY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224815\x22,\x22lati\x22\x3A\x2248.885111\x22,\x22long\x22\x3A\x222.266186\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20PANTIN\x22,\x22id\x22\x3A\x224845\x22,\x22lati\x22\x3A\x2248.896479\x22,\x22long\x22\x3A\x222.401907\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20PUTEAUX\x22,\x22id\x22\x3A\x224816\x22,\x22lati\x22\x3A\x2248.8843\x22,\x22long\x22\x3A\x222.236835\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20RUEIL\x20MALMAISON\x22,\x22id\x22\x3A\x224817\x22,\x22lati\x22\x3A\x2248.877939\x22,\x22long\x22\x3A\x222.180679\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20CLOUD\x22,\x22id\x22\x3A\x224818\x22,\x22lati\x22\x3A\x2248.843706\x22,\x22long\x22\x3A\x222.219356\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x2DDENIS\x22,\x22id\x22\x3A\x224851\x22,\x22lati\x22\x3A\x2248.936005\x22,\x22long\x22\x3A\x222.358906\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20MANDE\x22,\x22id\x22\x3A\x225407\x22,\x22lati\x22\x3A\x2248.843501\x22,\x22long\x22\x3A\x222.419041\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20MAURICE\x22,\x22id\x22\x3A\x224873\x22,\x22lati\x22\x3A\x2248.818091\x22,\x22long\x22\x3A\x222.423183\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20OUEN\x22,\x22id\x22\x3A\x224850\x22,\x22lati\x22\x3A\x2248.912188\x22,\x22long\x22\x3A\x222.333285\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SCEAUX\x22,\x22id\x22\x3A\x224819\x22,\x22lati\x22\x3A\x2248.778775\x22,\x22long\x22\x3A\x222.288772\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SEVRES\x22,\x22id\x22\x3A\x224820\x22,\x22lati\x22\x3A\x2248.824434\x22,\x22long\x22\x3A\x222.21308\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SURESNES\x22,\x22id\x22\x3A\x224821\x22,\x22lati\x22\x3A\x2248.87113\x22,\x22long\x22\x3A\x222.224667\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20THIAIS\x22,\x22id\x22\x3A\x224875\x22,\x22lati\x22\x3A\x2248.765315\x22,\x22long\x22\x3A\x222.388829\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VANVES\x22,\x22id\x22\x3A\x224822\x22,\x22lati\x22\x3A\x2248.821396\x22,\x22long\x22\x3A\x222.289619\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VELIZY\x20VILLACOUBLAY\x22,\x22id\x22\x3A\x224558\x22,\x22lati\x22\x3A\x2248.782531\x22,\x22long\x22\x3A\x222.191265\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VILLEJUIF\x22,\x22id\x22\x3A\x224876\x22,\x22lati\x22\x3A\x2248.794931\x22,\x22long\x22\x3A\x222.366248\x22\x7D,\x7B\x22name\x22\x3A\x22mairie\x20de\x20Villeneuve\x2Dla\x2DGarenne\x22,\x22id\x22\x3A\x223990\x22,\x22lati\x22\x3A\x2248.935596\x22,\x22long\x22\x3A\x222.332934\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VIROFLAY\x22,\x22id\x22\x3A\x224559\x22,\x22lati\x22\x3A\x2248.799422\x22,\x22long\x22\x3A\x222.172793\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VITRY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224878\x22,\x22lati\x22\x3A\x2248.788757\x22,\x22long\x22\x3A\x222.38929\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20LE\x20KREMLIN\x20BICETRE\x22,\x22id\x22\x3A\x225400\x22,\x22lati\x22\x3A\x2248.812652\x22,\x22long\x22\x3A\x222.356646\x22\x7D,\x7B\x22name\x22\x3A\x22Pr\x5Cu00e9fecture\x20de\x20Police\x20\x20\x2D\x20Site\x20de\x20Gesvres\x204\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224470\x22,\x22lati\x22\x3A\x2248.856894\x22,\x22long\x22\x3A\x222.348783\x22\x7D\x5D"));
?>
Your json_encode is encoding unicode characters and they are being escaped. You can change this behaviour by passing the flag JSON_UNESCAPED_UNICODE as second parameter.
echo json_encode($array, JSON_UNESCAPED_UNICODE);
Make sure you're using double quotes:
<?php
$string = "\x5B\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20d\x27Asni\x5Cu00e8res\x20sur\x20Seine\x20Belfort\x22,\x22id\x22\x3A\x225337\x22,\x22lati\x22\x3A\x2248.907864\x22,\x22long\x22\x3A\x222.268167\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20d\x27Asni\x5Cu00e8res\x20sur\x20Seine\x20Les\x20Hauts\x20d\x27Asni\x5Cu00e8res\x22,\x22id\x22\x3A\x225338\x22,\x22lati\x22\x3A\x2248.925983\x22,\x22long\x22\x3A\x222.274256\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Bagneux\x20Port\x20Galand\x22,\x22id\x22\x3A\x225339\x22,\x22lati\x22\x3A\x2248.788372\x22,\x22long\x22\x3A\x222.317539\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Bois\x20Colombes\x20Les\x20Bruy\x5Cu00e8res\x22,\x22id\x22\x3A\x225340\x22,\x22lati\x22\x3A\x2248.908581\x22,\x22long\x22\x3A\x222.262088\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Colombes\x20Foss\x5Cu00e9\x20Jean\x22,\x22id\x22\x3A\x225342\x22,\x22lati\x22\x3A\x2248.93106\x22,\x22long\x22\x3A\x222.267059\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Colombes\x20Wiener\x22,\x22id\x22\x3A\x225343\x22,\x22lati\x22\x3A\x2248.915141\x22,\x22long\x22\x3A\x222.246733\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Courbevoie\x20\x2D\x20Quartier\x20de\x20B\x5Cu00e9con\x22,\x22id\x22\x3A\x225344\x22,\x22lati\x22\x3A\x2248.901328\x22,\x22long\x22\x3A\x222.265769\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20de\x20Courbevoie\x20\x2D\x20Quartier\x20Faubourg\x20de\x20l\x27Arche\x22,\x22id\x22\x3A\x225345\x22,\x22lati\x22\x3A\x2248.897737\x22,\x22long\x22\x3A\x222.238265\x22\x7D,\x7B\x22name\x22\x3A\x22Annexe\x20Mairie\x20Meudon\x20la\x20For\x5Cu00eat\x20Place\x20Centrale\x22,\x22id\x22\x3A\x225346\x22,\x22lati\x22\x3A\x2248.787749\x22,\x22long\x22\x3A\x222.227974\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2010\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224463\x22,\x22lati\x22\x3A\x2248.871982\x22,\x22long\x22\x3A\x222.357889\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2012\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224464\x22,\x22lati\x22\x3A\x2248.840246\x22,\x22long\x22\x3A\x222.388204\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2014\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224465\x22,\x22lati\x22\x3A\x2248.832864\x22,\x22long\x22\x3A\x222.326462\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2015\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224475\x22,\x22lati\x22\x3A\x2248.841647\x22,\x22long\x22\x3A\x222.299668\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2016\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224466\x22,\x22lati\x22\x3A\x2248.863973\x22,\x22long\x22\x3A\x222.277212\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2017\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224467\x22,\x22lati\x22\x3A\x2248.883034\x22,\x22long\x22\x3A\x222.32408\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2018\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224468\x22,\x22lati\x22\x3A\x2248.892666\x22,\x22long\x22\x3A\x222.337346\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2019\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224461\x22,\x22lati\x22\x3A\x2248.876334\x22,\x22long\x22\x3A\x222.39318\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x2020\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224469\x22,\x22lati\x22\x3A\x2248.864976\x22,\x22long\x22\x3A\x222.39871\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x205\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224471\x22,\x22lati\x22\x3A\x2248.846319\x22,\x22long\x22\x3A\x222.344516\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x207\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224472\x22,\x22lati\x22\x3A\x2248.856888\x22,\x22long\x22\x3A\x222.319964\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x208\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224473\x22,\x22lati\x22\x3A\x2248.877862\x22,\x22long\x22\x3A\x222.317804\x22\x7D,\x7B\x22name\x22\x3A\x22Antenne\x20de\x20Police\x209\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224474\x22,\x22lati\x22\x3A\x2248.872497\x22,\x22long\x22\x3A\x222.340366\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20d\x27ALFORTVILLE\x22,\x22id\x22\x3A\x225392\x22,\x22lati\x22\x3A\x2248.80529\x22,\x22long\x22\x3A\x222.420021\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20d\x27ARCUEIL\x22,\x22id\x22\x3A\x225032\x22,\x22lati\x22\x3A\x2248.805973\x22,\x22long\x22\x3A\x222.336826\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20ASNIERES\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224799\x22,\x22lati\x22\x3A\x2248.910354\x22,\x22long\x22\x3A\x222.289417\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20AUBERVILLIERS\x22,\x22id\x22\x3A\x224825\x22,\x22lati\x22\x3A\x2248.914652\x22,\x22long\x22\x3A\x222.381673\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BAGNEUX\x22,\x22id\x22\x3A\x224800\x22,\x22lati\x22\x3A\x2248.798652\x22,\x22long\x22\x3A\x222.304296\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BAGNOLET\x22,\x22id\x22\x3A\x224827\x22,\x22lati\x22\x3A\x2248.868921\x22,\x22long\x22\x3A\x222.417979\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BOIS\x20COLOMBES\x22,\x22id\x22\x3A\x224824\x22,\x22lati\x22\x3A\x2248.914476\x22,\x22long\x22\x3A\x222.267797\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20BOULOGNE\x20BILLANCOURT\x22,\x22id\x22\x3A\x224801\x22,\x22lati\x22\x3A\x2248.835388\x22,\x22long\x22\x3A\x222.24031\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CACHAN\x22,\x22id\x22\x3A\x224859\x22,\x22lati\x22\x3A\x2248.794443\x22,\x22long\x22\x3A\x222.331244\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHARENTON\x20LE\x20PONT\x22,\x22id\x22\x3A\x225395\x22,\x22lati\x22\x3A\x2248.819851\x22,\x22long\x22\x3A\x222.415667\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATENAY\x20MALABRY\x22,\x22id\x22\x3A\x224802\x22,\x22lati\x22\x3A\x2248.767087\x22,\x22long\x22\x3A\x222.277421\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATILLON\x22,\x22id\x22\x3A\x225382\x22,\x22lati\x22\x3A\x2248.799868\x22,\x22long\x22\x3A\x222.289823\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHATOU\x22,\x22id\x22\x3A\x224531\x22,\x22lati\x22\x3A\x2248.890074\x22,\x22long\x22\x3A\x222.157537\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CHOISY\x20LE\x20ROI\x22,\x22id\x22\x3A\x224861\x22,\x22lati\x22\x3A\x2248.762448\x22,\x22long\x22\x3A\x222.406938\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CLAMART\x22,\x22id\x22\x3A\x224803\x22,\x22lati\x22\x3A\x2248.800313\x22,\x22long\x22\x3A\x222.263162\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20CLICHY\x22,\x22id\x22\x3A\x224804\x22,\x22lati\x22\x3A\x2248.902389\x22,\x22long\x22\x3A\x222.304312\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20COLOMBES\x22,\x22id\x22\x3A\x224805\x22,\x22lati\x22\x3A\x2248.92276\x22,\x22long\x22\x3A\x222.254343\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20COURBEVOIE\x22,\x22id\x22\x3A\x224806\x22,\x22lati\x22\x3A\x2248.895463\x22,\x22long\x22\x3A\x222.2565\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20DRANCY\x22,\x22id\x22\x3A\x224831\x22,\x22lati\x22\x3A\x2248.925691\x22,\x22long\x22\x3A\x222.389513\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20FRESNES\x22,\x22id\x22\x3A\x225398\x22,\x22lati\x22\x3A\x2248.75534\x22,\x22long\x22\x3A\x222.322471\x22\x7D,\x7B\x22name\x22\x3A\x22mairie\x20de\x20Garches\x22,\x22id\x22\x3A\x225287\x22,\x22lati\x22\x3A\x2248.843147\x22,\x22long\x22\x3A\x222.186586\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20GENNEVILLIERS\x22,\x22id\x22\x3A\x224807\x22,\x22lati\x22\x3A\x2248.925846\x22,\x22long\x22\x3A\x222.294367\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20HOUILLES\x22,\x22id\x22\x3A\x224535\x22,\x22lati\x22\x3A\x2248.923084\x22,\x22long\x22\x3A\x222.186666\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20ISSY\x20LES\x20MOULINEAUX\x22,\x22id\x22\x3A\x224808\x22,\x22lati\x22\x3A\x2248.82423\x22,\x22long\x22\x3A\x222.273643\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20IVRY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224864\x22,\x22lati\x22\x3A\x2248.807809\x22,\x22long\x22\x3A\x222.374647\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20L\x27HAY\x20LES\x20ROSES\x22,\x22id\x22\x3A\x224868\x22,\x22lati\x22\x3A\x2248.778867\x22,\x22long\x22\x3A\x222.337234\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LA\x20COURNEUVE\x22,\x22id\x22\x3A\x224835\x22,\x22lati\x22\x3A\x2248.926341\x22,\x22long\x22\x3A\x222.391157\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LA\x20GARENNE\x20COLOMBES\x22,\x22id\x22\x3A\x224809\x22,\x22lati\x22\x3A\x2248.906762\x22,\x22long\x22\x3A\x222.246125\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20BOURGET\x22,\x22id\x22\x3A\x224837\x22,\x22lati\x22\x3A\x2248.934871\x22,\x22long\x22\x3A\x222.425765\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20PLESSIS\x20ROBINSON\x22,\x22id\x22\x3A\x224823\x22,\x22lati\x22\x3A\x2248.78248\x22,\x22long\x22\x3A\x222.262036\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LE\x20PRE\x20SAINT\x20GERVAIS\x22,\x22id\x22\x3A\x224838\x22,\x22lati\x22\x3A\x2248.883069\x22,\x22long\x22\x3A\x222.403281\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LES\x20LILAS\x22,\x22id\x22\x3A\x224840\x22,\x22lati\x22\x3A\x2248.880519\x22,\x22long\x22\x3A\x222.41849\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20LEVALLOIS\x22,\x22id\x22\x3A\x224810\x22,\x22lati\x22\x3A\x2248.893086\x22,\x22long\x22\x3A\x222.288514\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MALAKOFF\x22,\x22id\x22\x3A\x224811\x22,\x22lati\x22\x3A\x2248.820888\x22,\x22long\x22\x3A\x222.301668\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MEUDON\x22,\x22id\x22\x3A\x224812\x22,\x22lati\x22\x3A\x2248.812558\x22,\x22long\x22\x3A\x222.238593\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20MONTROUGE\x22,\x22id\x22\x3A\x224813\x22,\x22lati\x22\x3A\x2248.818705\x22,\x22long\x22\x3A\x222.319896\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20NANTERRE\x22,\x22id\x22\x3A\x224814\x22,\x22lati\x22\x3A\x2248.892044\x22,\x22long\x22\x3A\x222.205266\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20NEUILLY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224815\x22,\x22lati\x22\x3A\x2248.885111\x22,\x22long\x22\x3A\x222.266186\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20PANTIN\x22,\x22id\x22\x3A\x224845\x22,\x22lati\x22\x3A\x2248.896479\x22,\x22long\x22\x3A\x222.401907\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20PUTEAUX\x22,\x22id\x22\x3A\x224816\x22,\x22lati\x22\x3A\x2248.8843\x22,\x22long\x22\x3A\x222.236835\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20RUEIL\x20MALMAISON\x22,\x22id\x22\x3A\x224817\x22,\x22lati\x22\x3A\x2248.877939\x22,\x22long\x22\x3A\x222.180679\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20CLOUD\x22,\x22id\x22\x3A\x224818\x22,\x22lati\x22\x3A\x2248.843706\x22,\x22long\x22\x3A\x222.219356\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x2DDENIS\x22,\x22id\x22\x3A\x224851\x22,\x22lati\x22\x3A\x2248.936005\x22,\x22long\x22\x3A\x222.358906\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20MANDE\x22,\x22id\x22\x3A\x225407\x22,\x22lati\x22\x3A\x2248.843501\x22,\x22long\x22\x3A\x222.419041\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20MAURICE\x22,\x22id\x22\x3A\x224873\x22,\x22lati\x22\x3A\x2248.818091\x22,\x22long\x22\x3A\x222.423183\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SAINT\x20OUEN\x22,\x22id\x22\x3A\x224850\x22,\x22lati\x22\x3A\x2248.912188\x22,\x22long\x22\x3A\x222.333285\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SCEAUX\x22,\x22id\x22\x3A\x224819\x22,\x22lati\x22\x3A\x2248.778775\x22,\x22long\x22\x3A\x222.288772\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SEVRES\x22,\x22id\x22\x3A\x224820\x22,\x22lati\x22\x3A\x2248.824434\x22,\x22long\x22\x3A\x222.21308\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20SURESNES\x22,\x22id\x22\x3A\x224821\x22,\x22lati\x22\x3A\x2248.87113\x22,\x22long\x22\x3A\x222.224667\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20THIAIS\x22,\x22id\x22\x3A\x224875\x22,\x22lati\x22\x3A\x2248.765315\x22,\x22long\x22\x3A\x222.388829\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VANVES\x22,\x22id\x22\x3A\x224822\x22,\x22lati\x22\x3A\x2248.821396\x22,\x22long\x22\x3A\x222.289619\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VELIZY\x20VILLACOUBLAY\x22,\x22id\x22\x3A\x224558\x22,\x22lati\x22\x3A\x2248.782531\x22,\x22long\x22\x3A\x222.191265\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VILLEJUIF\x22,\x22id\x22\x3A\x224876\x22,\x22lati\x22\x3A\x2248.794931\x22,\x22long\x22\x3A\x222.366248\x22\x7D,\x7B\x22name\x22\x3A\x22mairie\x20de\x20Villeneuve\x2Dla\x2DGarenne\x22,\x22id\x22\x3A\x223990\x22,\x22lati\x22\x3A\x2248.935596\x22,\x22long\x22\x3A\x222.332934\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VIROFLAY\x22,\x22id\x22\x3A\x224559\x22,\x22lati\x22\x3A\x2248.799422\x22,\x22long\x22\x3A\x222.172793\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20de\x20VITRY\x20SUR\x20SEINE\x22,\x22id\x22\x3A\x224878\x22,\x22lati\x22\x3A\x2248.788757\x22,\x22long\x22\x3A\x222.38929\x22\x7D,\x7B\x22name\x22\x3A\x22Mairie\x20LE\x20KREMLIN\x20BICETRE\x22,\x22id\x22\x3A\x225400\x22,\x22lati\x22\x3A\x2248.812652\x22,\x22long\x22\x3A\x222.356646\x22\x7D,\x7B\x22name\x22\x3A\x22Pr\x5Cu00e9fecture\x20de\x20Police\x20\x20\x2D\x20Site\x20de\x20Gesvres\x204\x5Cu00e8me\x20arrondissement\x22,\x22id\x22\x3A\x224470\x22,\x22lati\x22\x3A\x2248.856894\x22,\x22long\x22\x3A\x222.348783\x22\x7D\x5D";
var_dump(json_decode($string,true));
The above code works OK for me. Good luck!!

Convert accented UTF8 codes to characters using PHP

How can i convert string like this
%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9
to this:
ฤพลกฤลฅลพ-รฝรกรญรฉ
using PHP ?
Just use urldecode() function, because you have url encoded string.
$encoded = '%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9';
$decoded = urldecode($encoded);
echo $decoded;
outputs:
ฤพลกฤลฅลพ-รฝรกรญรฉ
Just use urldecode() function in php. Use the code below
<?php
$string = "%C4%BE%C5%A1%C4%8D%C5%A5%C5%BE-%C3%BD%C3%A1%C3%AD%C3%A9";
echo urldecode($string); // Outputs ฤพลกฤลฅลพ-รฝรกรญรฉ
?>
Hope this helps you

json_encode function: special characters

Elements of an array containing special characters are converted to empty strings when encoding the array with json_encode:
$arr = array ( "funds" => "ComStage STOXXยฎEurope 600 Techn NR ETF", "time"=>....);
$json = json_encode($arr);
After JSON encoding the element [funds] is null. It happens only with special characters (copyright, trademark etc) like the ones in "ComStage STOXXยฎEurope 600 Techn NR ETF".
Any suggestions?
Thanks
UPDATE: This is what solved the problem prior to populating the array (all names are taken from the db):
$mysqli->query("SET NAMES 'utf8'");
The manual for json_encode specifies this:
All string data must be UTF-8 encoded.
Thus, try array_mapping utf8_encode() to your array before you encode it:
$arr = array_map('utf8_encode', $arr);
$json = json_encode($arr);
// {"funds":"ComStage STOXX\u00c2\u00aeEurope 600 Techn NR ETF"}
For reference, take a look at the differences between the three examples on this fiddle. The first doesn't use character encoding, the second uses htmlentities and the third uses utf8_encode - they all return different results.
For consistency, you should use utf8_encode().
Docs
json_encode()
utf8_encode()
array_map()
Your input has to be encoded as UTF-8 or ISO-8859-1.
http://www.php.net/manual/en/function.json-encode.php
Because if you try to convert an array of non-utf8 characters you'll be getting 0 as return value.
Since 5.5.0 The return value on failure was changed from null string to FALSE.
To me, it works this way:
# Creating the ARRAY from Result.
$array=array();
while($row = $result->fetch_array(MYSQL_ASSOC))
{
# Converting each column to UTF8
$row = array_map('utf8_encode', $row);
array_push($array,$row);
}
json_encode($array);
you should use this code:
$json = json_encode(array_map('utf8_encode', $arr))
array_map function converts special characters in UTF8 standard
Use the below function.
function utf8_converter($array)
{
array_walk_recursive($array, function (&$item, $key) {
if (!mb_detect_encoding($item, 'utf-8', true)) {
$item = utf8_encode($item);
}
});
return $array;
}
To avoid escaping of special characters, I'm passing the flag:
JSON_UNESCAPED_UNICODE
Like this:
json_encode($array, JSON_UNESCAPED_UNICODE)
Use this code
mysql_set_charset("UTF8", $connection);
Example
$connection = mysql_connect(DB_HOST_GATEWAY,DB_USER_GATEWAY, DB_PASSWORD_GATEWAY);
mysql_set_charset("UTF8", $connection);
mysql_select_db(DB_DATABASE_GATEWAY,$connection);
you should add charset=UTF-8 in meta tag and use json_encode for special characters
$json = json_encode($arr);
json_encode function converts special characters in UTF8 standard
To fix the special character issue you just have to do 2 things
1.mysql_set_charset('utf8'); // set this line on top of your page in which you are using json.
If you are saving json data in database make sure that the particular column collation is set to "latin1_swedish_ci".

Categories