json转化为java实体

  import net.sf.json.JSONObject;

Map<String, Object> classMap = new HashMap<String, Object> ();
classMap.put( "OutInTask", OutInTask.class );
OutInTask bean = (OutInTask)JSONObject.toBean(JSONObject.fromObject(json), OutInTask.class, classMap);

 

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

ObjectMapper mapper = new ObjectMapper();
Map<String,Object> productMap = mapper.readValue(jsonResult,Map.class);

posted @ 2014-10-16 17:19  Silababy  阅读(232)  评论(0编辑  收藏  举报