Wrong escaping of characters in json (also tab)
poser55 opened this issue · comments
When using the json in other json frameworks, we get the following exception:
com.fasterxml.jackson.databind.ObjectMapper jsonMapper = ...;
jsonNode = jsonMapper.readTree(jsonAsString); // line with exception:
c.f.j.c.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value
at [Source: (StringReader); line: 1, column: 85933]
at c.f.j.c.JsonParser._constructError(JsonParser.java:1804)
at c.f.j.c.b.ParserMinimalBase._reportError(ParserMinimalBase.java:693)
at c.f.j.c.b.ParserMinimalBase._throwUnquotedSpace(ParserMinimalBase.java:657)
at c.f.j.c.j.ReaderBasedJsonParser._finishString2(ReaderBasedJsonParser.java:2053)
at c.f.j.c.j.ReaderBasedJsonParser._finishString(ReaderBasedJsonParser.java:2024)
at c.f.j.c.j.ReaderBasedJsonParser.getText(ReaderBasedJsonParser.java:278)
at c.f.j.d.d.s.BaseNodeDeserializer.deserializeObject(JsonNodeDeserializer.java:264)
at c.f.j.d.d.s.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:68)
at c.f.j.d.d.s.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:15)
at c.f.j.d.ObjectMapper._readTreeAndClose(ObjectMapper.java:4057)
at c.f.j.d.ObjectMapper.readTree(ObjectMapper.java:2552)
Escapes or unescapes a JSON string removing traces of offending characters that could prevent parsing.
The following characters are reserved in JSON and must be properly escaped to be used in strings:
• Backspace is replaced with \b
• Form feed is replaced with \f
• Newline is replaced with \n
• Carriage return is replaced with \r
• Tab is replaced with \t
• Double quote is replaced with "
• Backslash is replaced with \
Use the new method:
Record.asJsonNode()
We have now extended the tests that test this part better (they compare the old and new json export).