使用fastjson修改json字符串数据
String jsonString = orderAppService.getItemJson(orderId);
JSONArray jsonArray = JSONObject.parseArray(jsonString);
for (Integer i = 0; i < jsonArray.size();i++){
Integer productId = Integer.valueOf(jsonArray.getJSONObject(i).getString("product_id"));
if (productId == goodsId){
// 直接修改
jsonArray.getJSONObject(i).put("state",1);
break;
}
}