0

The problem with the following JSON response parsing is that is giving the error as "Unterminated object at character 32".

{
    "0": {
        "review": {
            "reviewTime": "2015-09-24 22:07:03",
            "author": "John Doe",
            "rating_5": 1.5,
            "rating": 2
        }
    },
    "1": {
        "review": {
            "reviewTime": "2015-09-25 18:05:14",
            "author": "Samantha",
            "rating_5": 5,
            "timestamp": 1443184514,
            "rating": 5
        }
    },
    "count": 3,
    "review_url": "https://localhost/reviews"
}
AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
  • Could you please post java code where you parse data? – Vitaly Zinchenko Sep 26 '15 at 15:44
  • @VitalyZinchenko I'm trying to parse using this `JSONObject json = new JSONObject(result.toString());` – Arjun Nemical Sep 26 '15 at 15:57
  • Could you please somehow stop your program at the line before JSONObject json = new JSONObject(result.toString()); and get result.toString() value? – Vitaly Zinchenko Sep 26 '15 at 16:10
  • @VitalyZinchenko The response will look like following: `{ count=2041.0, 4={review={reviewTime=2015-09-24 22:07:03, author=Neha Primith, rating_5=1.5, rating=2.0, reviewTimeFriendly=yesterday}}, 1={review={reviewTime=2015-09-24 22:07:03, author= John Doe, rating_5=1.5, rating=2.0,}}, 0={review={reviewTime=2015-09-25 18:05:14, author=Samantha, rating_5=5.0, rating=5.0}}, , review_url=https://localhost/reviews,count=2 }` – Arjun Nemical Sep 26 '15 at 16:19

2 Answers2

0

I'm validated your json using in http://jsonformatter.curiousconcept.com/ and it's valid. The 32 character is a date and must be quoted. Check in debug mode if the date is quoted.

  • Yes its valid. But how to parse it in android ? – Arjun Nemical Sep 26 '15 at 16:25
  • This isn't jsonobject valid: { count=2041.0, 4={review={reviewTime=2015-09-24 22:07:03, author=Neha Primith, rating_5=1.5, rating=2.0, reviewTimeFriendly=yesterday}}, 1={review={reviewTime=2015-09-24 22:07:03, author= John Doe, rating_5=1.5, rating=2.0,}}, 0={review={reviewTime=2015-09-25 18:05:14, author=Samantha, rating_5=5.0, rating=5.0}}, , review_url=https://localhost/reviews,count=2 } – Rafael Pivetta Balbuena Sep 26 '15 at 17:02
  • For parse json in android the post can help you: http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android?rq=1 – Rafael Pivetta Balbuena Sep 26 '15 at 17:13
0

In one of your comments to your question you wrote that your response looks like:

{ count=2041.0, 4={review={reviewTime=2015-09-24 22:07:03, author=Neha Primith, rating_5=1.5, rating=2.0, reviewTimeFriendly=yesterday}}, 1={review={reviewTime=2015-09-24 22:07:03, author= John Doe, rating_5=1.5, rating=2.0,}}, 0={review={reviewTime=2015-09-25 18:05:14, author=Samantha, rating_5=5.0, rating=5.0}}, , review_url=https://localhost/reviews,count=2 }

But it's not json format. Json format is sensitive to quotes. So make sure you get a properly formatted response

Vitaly Zinchenko
  • 4,871
  • 5
  • 36
  • 52