对对象进行JSON序列化,会得到类似key:value的形式。
但是如果对一个String字符串进行JSON序列化会得到什么?
测试下:

public class TestMain2 {
    public static void main(String args[]){
        String s = "a";
        System.out.println(JSON.toJSONString(s));
        System.out.println(s);
    }
}

输出:序列化后的结果被双引号包括。

对String对象进行JSON序列化

而该双引号包含的字符串也的确是JSON格式,可以被JSON工具识别。
对String对象进行JSON序列化

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-12-24
  • 2021-11-24
  • 2021-11-13
  • 2022-03-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
相关资源
相似解决方案