java解析JSON字符串
java解析JSON字符串的方法:
String jsonStr = "[{"product_id":"7AE370D2-E212-49DC-85DF-EB900E02F0AB","is_anonymous":"0"},{"product_id":"A8720D7F-5FD0-4D9E-A30E-3918264C6772","is_anonymous":"0"}]"
JSONArray jsonArray;
try {
jsonArray = new JSONArray(productStr);
int iSize = jsonArray.length();
for(int i = 0; i < iSize; i++) {
JSONObject jsonObj = jsonArray.getJSONObject(i);
String product_id = jsonObj.get("product_id").toString();
String is_anonymous = jsonObj.get("is_anonymous").toString();
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}