json={"id":1,"date":1359121059785,filter:["a","b","c"]}
如何通过Jackson Json拿到 filter的字符串
要类似于JSONObject.fromObject(json).get(filter) 直接可以拿到filter
请问怎么做
json={"id":1,"date":1359121059785,filter:["a","b","c"]}
如何通过Jackson Json拿到 filter的字符串
要类似于JSONObject.fromObject(json).get(filter) 直接可以拿到filter
请问怎么做
收起
public static void getJson(){
String json = "{\"id\":1,\"date\":1359121059785,\"filter\":[\"a\",\"b\",\"c\"]}";
ObjectMapper mapper = new ObjectMapper();
try {
Map map = mapper.readValue(json, Map.class);
List stri = (List)map.get("filter");
for(String str:stri)
System.out.println(str);
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
报告相同问题?