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>>(){});
每件事都需要坚持!