Map<String, Object>转Object,Object转 Map<String, Object>

Map转Object

import com.alibaba.fastjson.JSON;

Map<String, Object> boneAgeOrderMap=boneAgeOrderService.getOne(boneAgeOrder);
System.out.println("Map"+boneAgeOrderMap);


BoneAgeOrderLog boneAgeOrderLog=JSON.parseObject(JSON.toJSONString(boneAgeOrderMap), BoneAgeOrderLog.class);
System.out.println("Object"+boneAgeOrderLog);

 

 

Object转Map

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;

BoneAgeOrderLog boneAgeOrderLog=new BoneAgeOrderLog();

{boneAgeOrderLog.put("key1", "value1");
boneAgeOrderLog.put("key2", "value2");}

Map<String, String> params = JSONObject.parseObject(obj.toJSONString(), new TypeReference<Map<String, String>>(){});

 

posted @ 2018-06-07 10:51  NAYNEHC  阅读(21448)  评论(0编辑  收藏  举报