import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; //字符串转为JSON对象 String strParam="{ \"callerid\": \"013941128270\" ,\"timestart\": \"2021-07-27 09:37:42\" , \"status\": \"ANSWERED\" }"; //将字符串转化成JSONObject JSONObject jsonParam= JSON.parseObject(strParam); //实例一个JSON对象 并赋值 JSONObject jsonParam = new JSONObject(); jsonParam.put("event","NewCdr"); jsonParam.put("callid","1627349862.433"); jsonParam.put("timestart","2021-07-27 09:37:42"); jsonParam.put("callfrom","1008"); //取JSON中的某个值 String event = jsonObj.get("event").toString(); String callid = jsonObj.get("callid").toString(); //得到一个JSON字符串 jsonParam.toJSONString()
标签:java,jsonParam,JSONObject,put,JSON,字符串,event From: https://www.cnblogs.com/hailexuexi/p/17884728.html