码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-06-07 14:19:37      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:ali   value   log   ams   order   src   geo   style   port   

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>>(){});

技术分享图片

 

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

标签:ali   value   log   ams   order   src   geo   style   port   

原文地址:https://www.cnblogs.com/hellokitty1/p/9149482.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!