json串转json对象的时候,转义符导致不能正常解析..

Exception in thread "main" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 29 path $.data
    at com.google.gson.internal.Streams.parse(Streams.java:60)
    at com.google.gson.JsonParser.parse(JsonParser.java:84)
    at com.google.gson.JsonParser.parse(JsonParser.java:59)
    at com.google.gson.JsonParser.parse(JsonParser.java:45)
    at zh.main(zh.java:17)
Caused by: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 29 path $.data
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1568)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:491)
    at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:414)
    at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:722)
    at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:698)
    at com.google.gson.internal.Streams.parse(Streams.java:48)
    ... 4 more

解决代码如下:

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class zh {
	public static void main(String[] args) throws Exception {
		String secret ="RVLiqsbZmP00VEccALok4+xQaT6WXprZEb+SnoxBTT1zoCQVcQq3agR0/hFtgpk9oK6oxPpc9xk56l2jdZb8XO1i5xam0ApTpP9s/wOrnbiLOy92XqYYMSXH7xVzRf4irqWmhc1GY94+ZQpSY5UsrvvnbseWuObwbFwr7RPdVXp8tkSJCvKcY3531hHKPvokFwu0JnxeP803rLfkQjcvPL6lQYSA5drCZEmjhvCVtmgFy7XfbPie6QEASElTNGMCkkQpYT2W45Qa1PNnxFgPVDEpvOZYrIXm49kKfOCDRRGbs3AVTCqx9XFthw3UJ0PW0CXwQ79945cofxbIBecSeBZ1fqUd/M5GMnzakRyaR+4e0J1VRuRcXkRc9Y3K54jGYLz5LBf8FMukT8tCHM79NSPmGIzYVtq+UOD39FBtKlYY+S3fbe3m85wy1MuHA7OqENdgABwVnjthhY/diEQUdugVrdFKEBALPFxiI+5+YcwtzjH/9NZnjJhylDwk2zi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7M9ylVd+jQUZBF1xje8FD8vIyCuYhxncgrc4LMhyeCJmJ4rS50KRB3x6qdLX5/BbNfmrw7LnVPTZL8w5c/G9rGSHOyLQFvZJSm0lqwXme/GnVnYQFyj6pwuY4c9ZfXkPx8SlCiFW5XpcF83UOdFdvDgxcdcgczq6Gl7RaU7FSGUYEIyp+LbOych0K5FfGV9KXmQh4uc36sVSxK2pAgLCnvR3bF8qSeT1xDhoMfY1i+qKJ1Md9rq+l4Au5NW3Wfv2gk3VJt+f2meR45hWf6QaucBduKyZjD+renrDl3JtvV3ZNDzfBPX4Zf9OWe3hbGdar+Z+lPmpEU6trmbitvtu7fe1W+ciPoFDxI0fx9DQV/ACL9xoSMbPqSVALIK/YoCi80AJv7+WZuYoIV8xwnd6Elbq6OI9D+XQpNANy2yFXoUKNtlRIlcAelkRIRakajl+Bgk//O/2hqE8nZrYz5s3OE3N4AYKe1LlSbNRKeSmmORNO1rzujOq4E1NRg2F2jwiXgARp1O51ZUg==";
		String dataStr = Rsa.getResult(secret);
		//jsonString.substring(0,jsonString.length()-1);
		System.out.println(dataStr);
		dataStr = dataStr.substring(1, dataStr.length() - 1);
        dataStr = dataStr.replace("\\\"", "\"");
        System.out.println(dataStr);
     /*   dataStr = dataStr.replace("\\\\\"", "\\\"");*/
        System.out.println(dataStr);
		JsonObject returnData = new JsonParser().parse(dataStr).getAsJsonObject();
		/*System.out.println("json===="+returnData.toString());
                    json串转json对象的时候,转义符导致不能正常解析..Exception in thread "main" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 29 path $.data at com.google.gson.internal.Streams.parse(Streams.java:60...
				
代码部分: "imageUrls": { "imageUrl1":"https://blog.csdn.net/qq_24504453/article/details/72510241x1.png", "imageUrl2":"https://blog.csdn.net/qq_24504453/article/details/72510241x2.png" "imageUr...
HTTP传输过程中错误解决com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 13 今天在跟安卓端调试程序的时候,安卓端传输过来有中文的地方突然就报了上述错误 说明:服务器端用的是restful架构 具体表现为,json转换报错,只能在http请求的地址中看到参数,程序中输出
在JS中快速转义JSON字符串。 手动转义小的JSON字符串比使用本机更快。 主要焦点是非常快速地检查不需要转义的字符串,同时还改善了转义自身或至少不低于JSON.stringify的条件。 运行基准测试( npm run benchmark )显示出以下好处: 节点./基准 JSON short non escaped x 2 , 884 , 878 ops/sec ± 2.25 % ( 95 runs sampled) this short non escaped x 13 , 082 , 026 ops/sec ± 1.47 % ( 93 runs sampled) JSON short full escape 1 x 2 , 768 , 607 ops/sec ± 1.85 % ( 86 runs sampled) this short full es
最近做项目调用接口返回比较复杂的json数据,在解析的时候一直报这样的错,sonSyntaxException:com.google.gson.stream.MalformedJsonException:Unterminated objec at line 1 column 423 path ....   把接收的json打印出来也是完整的。 到处查资料搞了好久,偶然机会看到关于编码问题,原
Gson gson = new Gson(); CarPecc carPecc = gson.fromJson(response.body().toString(),CarPecc.class); Gson gson = new Gson...
最近做了一个Android开源项目库汇总,里面集合了OpenDigg上的优质的Android开源项目库,方便移动开发人员便捷的找到自己需要的项目工具等,感兴趣的可以到GitHub上给个star。 MaterialDrawer ★7337 - 安卓抽屉效果实现方案 Side-Men...
使用 gson 解析json字符串时候出现了这个错误,由于,服务器返回的json 字符串中的值 value中有 空格,所以一直报这个错误 解决方法: String data = gson.toJson(dataMap.get("biz_response")); Map<String,Object> map = gson.fromJson(data.toString(),HashMa...
There was an unexpected error (type=Internal Server Error, status=500). com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 141 path $[0].jumpUrl com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJson
这个错误是由于操作的json字符串,使用string类型有误。 我要把object对象recomdList解析出来,应该是一个list<T>,代码里需要把recomdList转成string,我直接转报错,应该是转成json才对。JSONObject.toJSONString(recomdList) 一个object对象recomdList转成List<T>代码:
华为VR眼镜终于来了笨丫头什么叫收租啊我一瞪眼你把黄金器给我我交易给你金币黄金器直接丢在我的小卖部里或许能顶出一个高价你明白吗华为VR眼镜终于来了笨丫头什么叫收租啊我一瞪眼你把黄金器给我我交易给你金币黄金器直接丢在我的小卖部里或许能顶出一个高价你明白吗华为VR眼镜终于来了笨丫头什么叫收租啊我一瞪眼你把黄金器给我我交易给你金币黄金器直接丢在我的小卖部里或许能顶出一个高价你明白吗华为VR眼镜终于来了 ```javascript const escapedJson = '{"name":"John","age":25}'; const unescapedJson = JSON.parse(escapedJson); console.log(unescapedJson); 在上面的示例中,`escapedJson` 是一个转义后的 JSON 字符串。通过调用 `JSON.parse()` 方法,我们将其反转义为 JavaScript 对象。然后,可以使用 `console.log()` 打印出反转义后的 JSON 数据。 请确保传递给 `JSON.parse()` 方法的字符串是有效的 JSON 格式,否则可能会引发异常。如果字符串无效,可以使用 `try...catch` 语句来捕获异常并进行处理。 注意:`JSON.parse()` 方法只能用于解析合法的 JSON 字符串,对于非标准的 JSON 或包含 JavaScript 表达式的字符串,需要使用更高级的技术来处理
百度搜索 “多叉树结合JavaScript树形组件实现无限级树形结构(一种构建多级有序树形结构JSON(或XML)数据源的方法)” 百度网盘下载链接:https://pan.baidu.com/s/13-1Ra-eonZtEmFGXn7KLLg?pwd=2022 提取码:2022