1
<?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?

4
  • could it be "use_space" = true = to : ? Commented Feb 25, 2011 at 11:00
  • Ah, ok I can see the problem with: "use_space" = true } Commented Feb 25, 2011 at 11:00
  • when everthing in php then why using console?? Commented Feb 25, 2011 at 11:01
  • @diEcho: Hmmm, you are jumping to conclusions a bit there aren't you?. Who said everything was in PHP?. Commented Feb 25, 2011 at 11:04

3 Answers 3

4

That is because your JSON isn't valid. Check out here.

This:

"use_space" = true 

Must be:

"use_space" : true 
Sign up to request clarification or add additional context in comments.

Comments

3

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 }

1 Comment

Note to self: I MUST check for obvious errors before asking for help on SO ;)
1

$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);

?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.