I have a simple php structure with 3 nested arrays.
I do not use particular objects and I build myself the arrays with 2 nested loops.
Here is a sample of the var_dump of the array I want to convert to Json.
array (size=2)
'tram B' =>
array (size=2)
0 =>
array (size=3)
'name' => string 'Ile Verte' (length=9)
'distance' => int 298
'stationID' => int 762
1 =>
array (size=3)
'name' => string 'La Tronche H?pital' (length=18)
'distance' => int 425
'stationID' => int 771
16 =>
array (size=4)
0 =>
array (size=3)
'name' => string 'Bastille' (length=8)
'distance' => int 531
'stationID' => int 397
1 =>
array (size=3)
'name' => string 'Xavier Jouvin' (length=13)
'distance' => int 589
'stationID' => int 438
In another script I have a similar structure and json_encode
works fine.
So I don't understand why json_encode
won't work here.
Edit : there seems to be a problem with the encoding. When mb_detect_encoding
returns ASCII, the json_encode
works but when it returns UTF8, it doesn't work anymore.
Edit2 : json_last_error()
returns JSON_ERROR_UTF8
which means : Malformed UTF-8 characters, possibly incorrectly encoded.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…