Json轉map和List

import org.codehaus.jackson.map.ObjectMapper;

List<Map<String,Object>> listData=new ArrayList<Map<String,Object>>();

Map<String,Object> map=new HashMap<String, Object>();
map.put("id", 123);
listData.add(map);
Gson gson = new Gson();
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String,Object>> newMap=objectMapper.readValue(gson.toJson(listData), List.class);
System.out.println(newMap);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章