{
"emp_evn_rescue":{
"area":"1",
"reporterPhone":"420420",
"end_stake":"627.154",
"reason":"0",
"evn_num":"JYGD202211111336",
"description":"45244",
"source":"0",
"road_id":"1003",
"start_stake":"627.151",
"reporttime":"2022-11-11 13:36:21",
"org_id":"4408407592167014400",
"road_section_id":"4408622289126420000",
"direction":"0"
}
}
现在想在对象里再set进去俩个字段,两个字段都保存的固定的值,应该怎么写
1、首先这个JSONObject对象你是能获取到的对吧,假如是jsonObject
2、通过这个方法jsonObject.getJSONObject("emp_evn_rescue")获取到emp_evn_rescue的JSONObject对象,假如是jsonObject1
JSONObject jsonObject1=jsonObject.getJSONObject("emp_evn_rescue")
3、通过put的方法放进去你想要的两个字段,假如是user_id,user_name
jsonObject1.put("user_id",1);
jsonObject1.put("user_name","张三");
你要不用fastjson直接处理,可以用put方法set进去,要么转为map类型直接put