-
Notifications
You must be signed in to change notification settings - Fork 541
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
问题描述
对不可见字符没有处理,会引起异常
比如换行符现在可以转换成\n,但ascii为17的不可见字符没有处理,会引起异常。不是特定为17,是所有的不可见字符。
环境信息
请填写以下信息:
- OS信息: linux
- JDK信息: jdk1.8
- 版本信息:Fastjson2 2.0.6
重现步骤
char abc = 17;
String str =
"{\"test\": \"Pixel 民" + String.valueOf(abc) + "\n XL\"}";
Object object = com.alibaba.fastjson2.JSON.parse(str);
System.out.println(com.alibaba.fastjson.JSON.toJSONString(object, SerializerFeature.BrowserCompatible));
System.out.println(com.alibaba.fastjson2.JSON.toJSONString(object, JSONWriter.Feature.BrowserCompatible));
ObjectMapper objectMapper = new ObjectMapper();
System.out.println(objectMapper.writeValueAsString(object));
////输出结果
{"test":"Pixel \u6C11\u0011\n XL"}//中文被编码
{"test":"Pixel 民�\n XL"}//abc没有被编码
{"test":"Pixel 民\u0011\n XL"}//预期的结果
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working