0
{"phone":1234,"name":"rose","key":1,"country":"india"} 
{"phone":6789,"name":"jasmine","key":2,"country":"india"}

while reading this type of json data ,I'm getting this error:

Unexpected token LEFT BRACE({) at position 54.
    at org.json.simple.parser.JSONParser.parse(JSONParser.java:146)
    at org.json.simple.parser.JSONParser.parse(JSONParser.java:92)

Could anyone please help me resolve this error?

1 Answer 1

2

You seem to have 2 lines of JSON. Each line is a valid JSON object/document in of itself, however if you pass both lines together then it would not be a valid JSON document. Your options are

  1. Read each line as a separate entry and invoke the JSON parser on that line to produce a JSON object.

  2. Use an array to process both lines:

    [ {"phone":1234,"name":"rose","key":1,"country":"india"}, {"phone":6789,"name":"jasmine","key":2,"country":"india"} ]

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.