fastjson String转JSONObject时,key值出现$开头,value值会发生改变,且根据该key去get的时候会原样获得原本的JSONObject

yhxst69z  于 2023-02-04  发布在  其他
关注(0)|答案(2)|浏览(140)

示例String:{"schema" : {"$ref" : "#/defined/220.html"}}

zed5wv10

zed5wv101#

您好, 请你在指出问题的同时,最好在能指出版本号. 还有最好不要截图. 贴代码上来,方便我们给您解决问题.

mklgxw1f

mklgxw1f2#

您好, 请你在指出问题的同时,最好在能指出版本号. 还有最好不要截图. 贴代码上来,方便我们给您解决问题.

1.2.57和1.2.68都会有这种情况。

代码:
public static JSONObject specsJson(){
String str = "{"schema" : {"$ref" : "#/defined/220.html"}}";
System.out.println("str:" + str);
JSONObject json = JSONObject.parseObject(str);
return json;
}

public static void main(String[] args){
    Map<String, Object> map = specsMap();
    JSONObject json = specsJson();
    System.out.println("map -> " + map.get("schema"));
    System.out.println("json -> " + json.toJSONString());
}

相关问题