简体   繁体   中英

How to Parse the following json response in Android?

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM