0

I'm trying to figure out whats wrong with the following json data, i'm currently using http://jsonlint.com/ to validate it which keeps failing with;

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
  • Missing comma. That is all. Commented Dec 29, 2024 at 18:50

4 Answers 4

5

You've forgot a 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" } ] }} 
Sign up to request clarification or add additional context in comments.

Comments

2

Missing the 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" } ] } } 

Comments

2

you're missing a comma after the array closes.

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 }"; 

Comments

0

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

Between array of Questions, You missed COMMA after "Question 1" as answered by others. Let Plain Object to JSON string mapping be done by REST providers like JAKSON if you're using JERSEY. Otherwise, use other APIs for mapping.

The validation answers it clearly, however where exactly the comma is missing. The very common mistakes experienced are either missing { brace for object, [ bracket for representing arrays or ,(comma) for delimiting array of elements.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.