Lazy JsonParser crash on escaped double quote
slandelle opened this issue · comments
Stephane Landelle commented
Current behavior
{
"values": [
{
"value": "foo\"bar"
}
]
}
JsonParser.createLazyOne().parse(STRING);
Exception in thread "main" jodd.json.JsonException: Syntax error! End of JSON
offset: 59 near: "...}
]
}
"
at jodd.json.JsonParser.syntaxError(JsonParser.java:1197)
at jodd.json.JsonParser._parse(JsonParser.java:382)
at jodd.json.JsonParser.parse(JsonParser.java:348)
Expected behavior
Syntax is perfectly valid
Steps to Reproduce the Problem
see above.
Note that issue doesn't happen with the eager default parser.
Stephane Landelle commented
Here's a reproducer to be added in JsonParserTest
:
@Test
void testLazyParserSupportEscapedDoubleQuotes() {
String json = "{ \"values\": [{ \"value\": \"foo\\\"bar\" }]}";
JsonParsers.forEachParser(jsonParser -> {
Map<String, String> object = jsonParser.parse(json);
List<Map.Entry<String, String>> entries = object.entrySet().stream().collect(Collectors.toList());
assertEquals(1, entries.size());
assertEquals("values", entries.get(0).getKey());
});
}
Stephane Landelle commented
PR under way.
Stephane Landelle commented
Igor Spasić commented
@slandelle released :)
Stephane Landelle commented
Thanks a lot, man!