[QUESTION]是否可以支持反斜杠“\”而非转义字符的反序列化
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 请描述您的问题
*询问有关本项目的使用和其他方面的相关问题。*
```json
{
"property": {
"session": "client-sdkA",
"subject": "macs/ods/tagschema/unit01"
},
"message": {
"namespace": "HH800",
"values": [
{
"id": "AMACC1A8CNDWTRTEM.AM",
"type": "BYTE",
"description": "空冷1\8列凝结水温度(选取)"
},
{
"id": "AMACC1A8CNDWTRTEMXX.AM",
"type": "BYTE",
"description": "空冷1\8列凝结水温度选小"
}
]
}
}
```
通讯字符串对象如上,代码处理如下:
```java
public class JSONTest {
@Data
public static class OdsData{
private OdsDataProperty property;
private OdsDataMessage message;
@Data
public static class OdsDataProperty{
private String session;
private String subject;
}
@Data
public static class OdsDataMessage{
private String namespace;
private List values;
@Data
public static class OdsDataValue{
private String id;
private String type;
private String description;
}
}
}
/**
* Fastjson默认读特性
*/
JSONReader.Feature[] FASTJSON_DEFAULT_READER_FEATURES = {JSONReader.Feature.SupportSmartMatch, JSONReader.Feature.SupportArrayToBean, JSONReader.Feature.UseNativeObject, JSONReader.Feature.SupportClassForName,JSONReader.Feature.IgnoreSetNullValue,JSONReader.Feature.AllowUnQuotedFieldNames,JSONReader.Feature.IgnoreCheckClose,JSONReader.Feature.IgnoreAutoTypeNotMatch };
public static void main(String[] args) throws Exception {
OdsData obj2 = JSONObject.parseObject(jsonStri, OdsData.class,FASTJSON_DEFAULT_READER_FEATURES);
System.out.println(obj2);
}
}
```
期望可以正常转换
Contributor guide
Research direction
Start with the JSONObject.parseObject call and the JSONReader.Feature configuration shown, then verify how the parser handles the \8 sequence. The issue names no repository files or tests; done means the expected behavior for this non-standard escape is agreed and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100