java ObjectMapper json 与对象的相互转换

1 json string 转 JSONObject

 

try {
     JSONObject jsonObject = new JSONObject("{\"phonetype\":\"N95\",\"cat\":\"WP\"}");
}catch (JSONException err){
     Log.d("Error", err.toString());
}

 

2 json string 转 JsonNode

ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(jsonString);

3 json string 装map

Map<String, String> map = mapper.readValue(jsonstring, Map.class);

java ObjectMapper json 与对象的相互转换

上一篇:C++ set集合测试


下一篇:Could not open ServletContext resource [/WEB-INF/applicationContext.xml] 解决办法