杰克逊解析和\字符问题

时间:2016-03-21 11:54:43

标签: json rest jackson

我知道这个问题已经讨论了很多,但是对于发布到Spring RestController并返回到行的json数据,生成了字符(\ n):

这是我的json:

json = @"{""comment"":""" + comment + "\",\"sentFromReference\": \"" + fromRref + "\",\"chosenConductorNumber\": \"" + conductorNumber + "\",\"chosenVertJaune\": \"" + greenYellow + "\",\"chosenSection\": \"" + section + "\", \"projectId\":\""+projectId+"\" }";

在评论属性中,id写一行,然后开始一个新行,转换为:“comment”:“azpoeazpeou \ nazejaozije”

问题在于\ n

发生异常:

21-03-2016 11:49:51,693 [ervlet.mvc.support.DefaultHandlerExceptionResolver:377 :WARN ] http-bio-8080-exec-2 -  - Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value
at [Source: java.io.PushbackInputStream@7bd6f635; line: 1, column: 41] (through reference chain: com.rexel.volta.dto.TransfertDto["comment"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value

我实际上不想逃避反斜杠,我希望它被考虑在内。这怎么可能 ?我使用杰克逊版本1.9.13。谢谢你的帮助。

0 个答案:

没有答案