1.MyJsonUtils.toJsonString 
【toJsonString方法是自己定义的,详细如下】
public static String toJsonString(Object obj){
        String jsonStr = null;
        try {
            jsonStr =  mapper.writeValueAsString(obj);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return jsonStr;
    }
    

 

2. jsonObject.toString()
 
 
3.  jsonObject.toJSONString()
 
这个三个方法的都是将对象转为json字符串,2、3还需要先将对象转为JsonObject,那么这个三个方法的区别是什么???
jsonObject.toJSONString()将数

 

jsonObject.toJSONString()将数

 

 

 jsonObject.toJSONString()将数

java的Long型传到前端,再传回后端,你会发现少了些东西(后几位可能被取整了)

所以先将Long型转为String。

 

相关文章:

  • 2021-07-11
  • 2021-11-17
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-06-06
  • 2021-12-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
相关资源
相似解决方案