Closed hathiphant closed 3 years ago
@hathiphant
This is correct behavior provided by Jakarta JSON Processing API. Try the following code which uses Jakarta JSON Processing API directly without Justify.
String json = "2 3";
try (JsonReader reader = Json.createReader(new StringReader(json))) {
System.out.println(reader.readValue());
}
// result: 2 is printed
If you think this behavior is not good, please contact JSON-P project.
Thank you for your response and sorry to bother you. I reported the problem to your very good validator, because I was more surprised with a validating parser not detecting invalid data than a non-validating parser.
After searching in bugs of JSON-P, I have found eclipse-ee4j/jsonp#171 which seems to be the same problem, and does not seems to evolve. If I have too many uses of JsonReader, I will make my own JsonReader wrapping a JsonParser to detect this type of problems.
I perfectly understand if you close this issue, because the problem in data relates to JSON syntax and not JSON schema.
Thank you very much.
When using a JsonReader with a schema, the first value is read (and validated), but if there is some other characters after the valid JSON data, this is not detected as invalid (no exception or validation message that EOF is not attained). This can be solved with a JsonReader using internally a JsonParser with a loop
while (parser.hasNext())
to match fully the stream.