简体   繁体   English

如何在Android中解析以下json响应?

[英]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". 以下JSON响应解析的问题在于,错误为“字符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. 我在http://jsonformatter.curiousconcept.com/中使用验证了您的json,它是有效的。 The 32 character is a date and must be quoted. 32个字符是日期,必须用引号引起来。 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格式。 Json format is sensitive to quotes. Json格式对引号敏感。 So make sure you get a properly formatted response 因此,请确保您收到格式正确的回复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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