Reputation: 31
Code is written in 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?
Upvotes: 2
Views: 6397
Reputation: 11234
JSONArray resultArray = (JSONArray) resultObject;
for (int i=0;i<resultArray.length();i++){
JSONObject result = resultArray.getJSONObject(i);
System.out.println(result.getString("price"));
}
Upvotes: 1