0

I have a Json string to do some testing on nested Json but get te error:Unexpected character (':' (code 58)): was expecting comma to separate ARRAY entries at [line:1, column:83]

I can seem to figure out what is wrong with my Json

Here is my Json String

'{"Accts":[{"Name":"ABC","Exp":25,"Languages":[{"Name":"Apex","version":[]},"Name":"Java","versions":[{"version":1.8,"certification":true,"placeholder":{"target":"reached"}}]}]}]}'
1
  • 3
    Paste this into e.g. jsonformatter.curiousconcept.com (without the leading and trailing single quotes) and you will get detailed errors and the formatting helps you to see what is wrong too.
    – Keith C
    Jan 24, 2021 at 13:15

2 Answers 2

3

The error message is helpful here, line 1, column 83 puts you at "Name":"Java"

From the previous entry in the list, it's clear that you're missing an object start { after the "apex" language JSON object.

As usual, pretty-printing (and being diligent about indentation) makes it easy to see the issue.

{
    "Accts":
    [
        {
            "Name":"ABC",
            "Exp":25,
            "Languages":
            [
                // First entry is an object
                {
                    "Name":"Apex",
                    "version":[]
                },
                // Second entry isn't
                // Not an issue in and of itself, but a red flag
                "Name":"Java",
                "versions":
                [
                    {
                        "version":1.8,
                        "certification":true,
                        "placeholder":
                        {
                            "target":"reached"
                        }
                    }
                ]
            } // This terminator doesn't match the terminator on the same level
        ]
    }
]} //extra terminators indicate _something_ is wrong

2
  • Thanks for pointing pretty-printing out didnt knew about this tool this makes it a breeze.
    – Thomas
    Jan 24, 2021 at 21:36
  • @Thomas It's not a specific tool, but more of a concept. Basically, make things easy for people to read.
    – Derek F
    Jan 24, 2021 at 23:15
0

Based on the JASON you've supplied and the error messag, I'd expect something like the following:

{
    "Accts":
    [  // a list starts here
        {
            "Name":"ABC",
            "Exp":25,
            "Languages":
            [   // another list begins
                {  // 1st record in list is an object with a name of "Apex"
                    "Name":"Apex",
                    "version":[]  // note type of object
                },  // error message follows below
                    // This is a Name followed by a different object type of "versions" 
                    "Name":"Java",
                    "versions":
                    [
                        {
                            "version":1.8,
                            "certification":true,
                            "placeholder": 
                            {
                                "target":"reached"
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

So, I suspect the real issue is the type field type you've listed for the object/array of "version" vs "versions". If they were both "version", the error message would likely disappear provided the rest of your JASON conforms.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .