Reputation: 9333
<?php
$b = '{
"encoding" : "UTF-8",
"plug-ins" : [
"python",
"c++",
"ruby"
],
"indent" : { "length" : 3, "use_space" = true }
}';
print "\n\n\n=================================\n";
$barr = json_decode($b, true);
print_r($barr);
?>
This prints nothing on the console. Is tehre something wrong with the JSON format above? - or am I missing a trick?
Upvotes: 1
Views: 422
Reputation: 54016
$b = '{
"encoding" : "UTF-8",
"plug-ins" : [
"python",
"c++",
"ruby"
],
"indent" : { "length" : 3, "use_space" : true }
}';
print "\n\n\n=================================\n";
$barr = json_decode($b, true);
print_r($barr);
?>
Upvotes: 1
Reputation: 382616
That is because your JSON isn't valid. Check out here.
This:
"use_space" = true
Must be:
"use_space" : true
Upvotes: 4
Reputation: 723388
The indent
property has an error in its use_space
property:
"indent" : { "length" : 3, "use_space" = true }
The equal should be a colon.
"indent" : { "length" : 3, "use_space" : true }
Upvotes: 3