Code is written in java
代码是用java编写的
JSONArray resultArray = (JSONArray)resultObject;
String str = (resultArray.get(0).toString())
Now I have a string which is as follows
现在我有一个字符串,如下所示
{
"styleId": "2276730",
"price": "$199.95",
"originalPrice": "$199.95",
"colorId": "401",
"productName": "Mutiny",
"productId": "8149427",
"percentOff": "0%"
},
I want to have the value of price for each such array
我想知道每一个这样的数组的价格
I am a newbie to JSON. Can anyone help me with this?
我是JSON的新手。有人能帮我一下吗?
1 个解决方案
#1
1
JSONArray resultArray = (JSONArray) resultObject;
for (int i=0;i<resultArray.length();i++){
JSONObject result = resultArray.getJSONObject(i);
System.out.println(result.getString("price"));
}
#1
1
JSONArray resultArray = (JSONArray) resultObject;
for (int i=0;i<resultArray.length();i++){
JSONObject result = resultArray.getJSONObject(i);
System.out.println(result.getString("price"));
}