0

When I pass this through a JSON lint it doesn't appear as a nested JSON. How can I make this JSON nested properly?

var c = {
        "io_name" : "Fruits",
        "io_children" : [{
                    "io_name":"banana",
                    "io_name":"apple",
                    "io_name":"pear"
                    }]
    }
1
  • By "nested JSON" do you mean neatly formatted (assuming the repetition of io_name is a posting typo)? Or is it that "io_name" only appears once in the JSON (i.e. that the repeated property name is an error and jcolebrand has answered your question)? Commented Jul 6, 2011 at 6:18

1 Answer 1

3

Did you mean this?

var c = {
    "io_name" : "Fruits",
    "io_children" : [
                {"io_name":"banana"},
                {"io_name":"apple"},
                {"io_name":"pear"}
                ]
}

As it is, you're declaring an array that contains one object, and the object defines one key "io_name" and then redefines the value of that key three times (which is illogical at best)

Sign up to request clarification or add additional context in comments.

4 Comments

Was typing my answer whilst your answer appeared. Deleted it because of redundancy. But please explain SGITE for me?
It's a meta meme. Slowest Gun in the East. Meaning, you post the answers that already appear and ride the higher rep to getting more rep (because people follow high rep in voting for answers). As to "was typing my answer whilst your answer appeared" ... there was an 8 minute posting difference. A 90 second difference would make sense, but ....
You're a little paranoid here. I was multitasking on this (testbed.nicon.nl/randomness), my regular job and typing an answer to this question. :D
Nah, not paranoid, just concerned with making the stacks a better place (note my diamond on a sister-site) and annoyed at seeing 10k+ers playing SGITE

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.