java字符串为json格式的函数

Python012

java字符串为json格式的函数,第1张

java字符串为json格式的函数,函数名称语法说明 json_array_contains函数 json_array_contains(x, value) 判断JSON数组中是否包含某个值。 json_array_get函数 json_array_

string类型如果要转换成json的话,就需要写成这样的形式,如下:\x0d\x0aString jsonStr ="{'id':'11','parentId':'root','refObj':{'existType':'exist','deptType':'emp','treeNodeType':'dept'}}"\x0d\x0aJSONObject jsonObj = new JSONObject(jsonStr)\x0d\x0aJSONObject refObj = new JSONObject(jsonObj.getString("refObj"))\x0d\x0aString existType = refObj.getString("existType")\x0d\x0aSystem.out.println(existType)\x0d\x0ajar使用的是org.json.jar