Problems with the following json data

I'm trying to figure out what happened with the following json data, I am currently using http://jsonlint.com/ to check it, which keeps crashing;

Parse error on line 9:
...                    "Question 2" : [   
-----------------------^
Expecting 'EOF', '}', ',', ']'

My code

{ "questions" : {
                    "Question 1" : [
                    { "Q" :"Question" },
                    { "A" : "Answer A"  },
                    { "B" : "Answer B" },
                    { "C" : "Answer C" },
                    { "D" : "Answer D" },
                    { "Answer" : "C" }
                    ] 
                    "Question 2" : [
                    { "Q" :"Question" },
                    { "A" : "Answer A"  },
                    { "B" : "Answer B" },
                    { "C" : "Answer C" },
                    { "D" : "Answer D" },
                    { "Answer" : "C" }
                    ] 
}
                    }";
+1
source share
4 answers

You forgot the comma!

{ "questions" : {
                "Question 1" : [
                { "Q" :"Question" },
                { "A" : "Answer A"  },
                { "B" : "Answer B" },
                { "C" : "Answer C" },
                { "D" : "Answer D" },
                { "Answer" : "C" }
                ],
                "Question 2" : [
                { "Q" :"Question" },
                { "A" : "Answer A"  },
                { "B" : "Answer B" },
                { "C" : "Answer C" },
                { "D" : "Answer D" },
                { "Answer" : "C" }
                ] 
}}
+5
source

There is no comma between your question keys.

{ "questions" : {
                    "Question 1" : [
                    { "Q" :"Question" },
                    { "A" : "Answer A"  },
                    { "B" : "Answer B" },
                    { "C" : "Answer C" },
                    { "D" : "Answer D" },
                    { "Answer" : "C" }
                    ],
                    "Question 2" : [
                    { "Q" :"Question" },
                    { "A" : "Answer A"  },
                    { "B" : "Answer B" },
                    { "C" : "Answer C" },
                    { "D" : "Answer D" },
                    { "Answer" : "C" }
                    ] 
}
                    }
+2
source

.

JSON = { 
  "questions" : {
      "Question 1" : [
          { "Q" :"Question" },
          { "A" : "Answer A"  },
          { "B" : "Answer B" },
          { "C" : "Answer C" },
          { "D" : "Answer D" },
          { "Answer" : "C" }
      ],// end of Question 1 "this is where you'r missing the comma"
      "Question 2" : [
          { "Q" :"Question" },
          { "A" : "Answer A"  },
          { "B" : "Answer B" },
          { "C" : "Answer C" },
          { "D" : "Answer D" },
          { "Answer" : "C" }
      ] // end of Question 2
  }//end of questions object
}";
+2

'EOF', '}', ',', ']'

, COMMA " 1", . Plain Object JSON REST, JAKSON, JERSEY. API .

Verifying the correct answer to it clearly, however, where exactly the comma is missing. Very often there are errors that are missing {bracket for the object, [bracket for representing arrays or (comma) for delimiting an array of elements.

0
source

Source: https://habr.com/ru/post/1529841/


All Articles