user3415960
user3415960

Reputation: 11

What is wrong with this JSON file?

I put it in a parser and all it gives me is "expecting string on line 19". I have no idea what that means.

{
    "name": "Rajeev",
    "children": [
        {
            "name": "Joe",
            "children": [
                {
                    "name": "Kevin",
                    "children": [
                        {
                            "name": "George"
                        }
                    ]
                },
                {
                    "name": "John",
                    "children": [
                        {
                            "name": "Barb",

                        }{
                            "name": "Michael",

                        }{
                            "name": "Charles"
                        }
                    ]{
                        "name": "Ravinder"
                    ]
                },

Upvotes: 1

Views: 69

Answers (4)

martskins
martskins

Reputation: 2940

Sorry for the first answer, I saw a missing comma and automatically assumed that was it, but there were many other errors in there. I think this is what you're trying to do

[
        {
            "name": "Rajeev",
            "children": [
                {
                    "name": "Joe",
                    "children": [
                        {
                            "name": "Kevin",
                            "children": [
                                {
                                    "name": "George"
                                }
                            ]
                        },
                        {
                            "name": "John",
                            "children": [
                                {
                                    "name": "Barb"
                                },
                                {
                                    "name": "Michael"
                                },
                                {
                                    "name": "Charles"
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "name": "Ravinder"
        }
    ]

Upvotes: 0

Royi Namir
Royi Namir

Reputation: 148524

The left one is the right one. see for yourself. you had many extra , and unclosed { and [

https://i.sstatic.net/9yKNN.jpg enter image description here

Upvotes: 1

Stephen Thomas
Stephen Thomas

Reputation: 14053

Your commas are in the wrong place, e.g.

"children": [
                    {
                        "name": "Barb"

                    },{
                        "name": "Michael"

                    },{
                        "name": "Charles"
                    }
                ]

Upvotes: 1

Quentin
Quentin

Reputation: 943216

You have a property / value:

     "name": "Barb",

with a trailing comma so the next thing must be another property / value (the string mentioned in the error message is the property name).

However you have:

}{

Either remove the comma or add more details about Barb.

Then you will need to put a comma between the two objects:

}, {

It seems likely that you intended to place the comma causing teh error between the two objects, so you can just move them.

(You have similar errors throughout the rest of the file)

Upvotes: 0

Related Questions