我的数据就像结果集中的返回
[[{hostItemId=44, userId=1, title=This is the title 29 for skill(cleaning) for paid items..., description=This is the description 29 for skill ( cleaning) for paid items..., isFree=false, price=42.0, requestCount=2, categoryId=3, attachmentUrl=1478684543988image.jpg, currencySymbol=20B9, hostItemStatus=3, shareType=1}, {hostItemId=24, userId=1, title=This is title 15 for skill (spring chores)..., description=This is the description 15 for skill (spring chores)..., isFree=true, price=null, requestCount=2, categoryId=3, attachmentUrl=1478672337661image.jpg, currencySymbol=null, hostItemStatus=3, shareType=1}]]
答案 0 :(得分:1)
您提供的Json数据是错误的。它会抛出一个错误。 Json数据的正确语法是var jsondata = [
[
{
"hostItemId": 44,
"userId": 1,
"title": "This is the title 29 for skill(cleaning) for paid items...",
"description": "This is the description 29 for skill ( cleaning) for paid items...",
"isFree": false,
"price": 42,
"requestCount": 2,
"categoryId": 3,
"attachmentUrl": "1478684543988image.jpg",
"currencySymbol": "20B9",
"hostItemStatus": 3,
"shareType": 1
},
{
"hostItemId": 24,
"userId": 1,
"title": "This is title 15 for skill (spring chores)...",
"description": "This is the description 15 for skill (spring chores)...",
"isFree": true,
"price": null,
"requestCount": 2,
"categoryId": 3,
"attachmentUrl": "1478672337661image.jpg",
"currencySymbol": null,
"hostItemStatus": 3,
"shareType": 1
}
]
]
之后,您可以将此json字符串解码为您的对象。
// Creating a JSONObject from a String
JSONObject nodeRoot = new JSONObject(jsondata);
// Creating a sub-JSONObject from another JSONObject
JSONObject nodeStats = nodeRoot.getJSONObject("stats");