my json data that names are between ("") is working as following.
var_dump(json_decode('{"a":"foo","b":"bar"}', true));
but names are not between ("") is not working:
var_dump(json_decode('{a:"foo",b:"bar"}', true)) ;
my json data is coming from another server like this:
{a:"foo",b:"bar"}
and that json created by php with json_encode.
$rows = array();
while($r = mysqli_fetch_assoc($sql)) {
$rows[] = $r;
}
return json_encode($rows)
but json_decode returning NULL for this object.
Looks like you will have to modify the string before parsing it because that isn't valid JSON. You can check it with a site like this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.