In my project I have an int jsonobject
by 20 value. To get the int
value I used this:
model.setInt(jsonObject.getInt("price"));
Now it returns 0 value for price. How can I get real value?
Here is My out put Json:
"data": [
{
"id": "571dd7817f8b9a1c190bbdb5",
"goods": 0,
"rate": {
"r1": 0
},
"price": 20
}
Please look at the example:
String jsonData = "{\"count\": 20}";
JSONObject obj = new JSONObject(jsonData);
System.out.println("Count: " + obj.getInt("count"));
Your JSON
is invalid. you can use online tools like the jsonformatter to test the validity of your JSON
.
Maybe try something like:
{
"data": [
{
"id": "571dd7817f8b9a1c190bbdb5",
"goods": 0,
"rate": {"r1": 0},
"price": 20
}
]
}
Looking at your code, you may have better luck with this structure:
{
"id": "571dd7817f8b9a1c190bbdb5",
"goods": 0,
"rate": {"r1": 0},
"price": 20
}
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.