json - php json_decode with data wrapped by [ ] -


with true option, works fine.

sorry , guys.

=============================================

i encoded php array json code

$rows = array(); if ($result = $mysqli->query($query)) {     while ($row = $result->fetch_assoc()) {         $rows[] = $row;     }     echo json_encode($rows);     /* free result set */     $result->free(); } 

end decode with

$array = json_decode($server_output) 

the $server_output this

[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"ca"}] [{"userid":"153795","userinfor":"xxxxxxxxx","userlocation":"ca"}] [{"userid":"131878","userinfor":"xxxxxxxxx","userlocation":"ca"}] 

but, $array null :(

thanks in advence,

this not valid json together:

[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"ca"}] [{"userid":"153795","userinfor":"xxxxxxxxx","userlocation":"ca"}] [{"userid":"131878","userinfor":"xxxxxxxxx","userlocation":"ca"}] 

while, part valid:

[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"ca"}] 

or 1 of them separately

$json = '[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"ca"}]'; print_r(json_decode($json, true)); 

output:

array (     [0] => array         (             [userid] => 96679             [userinfor] => xxxxxxxxx             [userlocation] => ca         )  ) 

the valid format data this:

[     {         "userid": "96679",         "userinfor": "xxxxxxxxx",         "userlocation": "ca"     },     {         "userid": "153795",         "userinfor": "xxxxxxxxx",         "userlocation": "ca"     },     {         "userid": "131878",         "userinfor": "xxxxxxxxx",         "userlocation": "ca"     } ] 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -