Reputation: 6875
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.
Upvotes: 0
Views: 289
Reputation: 306
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.
Upvotes: 2