zoukankan      html  css  js  c++  java
  • 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>>(){});

  • 相关阅读:
    STL容器[26]
    SHELL[01]
    SHELL[04]
    SHELL[02]I/O重定向
    STL容器[39]
    stl.set用法总结
    STL容器[33]
    STL容器[29]
    hdu acm1071
    hdu acm 2673
  • 原文地址:https://www.cnblogs.com/hellokitty1/p/9149482.html
Copyright © 2011-2022 走看看