Parser don't throw exception when specific JSON is not valid
See original GitHub issueDescribe the bug When trying to parse invalid JSON, the parser doesn’t throw ParseException but parse the JSON. JSON:
{}something
Simple test:
public class JsonParseTest {
@Test
void testParsingJson() {
ObjectMapper objectMapper = new ObjectMapper();
assertThrows(JsonParseException.class, () -> objectMapper.readTree("{}something"));
}
}
Version information 2.13.1
To Reproduce
Just run the parsing (readTree
or readValue
) with incorrect JSON input as shown.
Expected behavior Parser throws JsonParseException
Additional context
Attached simple test project: jackson-parse-error.zip
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >Proper way to catch exception from JSON.parse - Stack Overflow
i post something into an iframe then read back the contents of the iframe with json parse...so sometimes it's not a json string....
Read more >What Is JSON and How to Handle an “Unexpected Token” Error
The first thing to do in this situation is to confirm where the error is happening exactly. To ensure the error happens on...
Read more >SyntaxError: JSON.parse unexpected character in JavaScript
The "SyntaxError: JSON.parse: unexpected character" error occurs when passing a value that is not a valid JSON string to the JSON.parse method, ...
Read more >SyntaxError: JSON.parse: bad parsing Breaking Your Code ...
Traveling deftly through to the next item in our JavaScript Error Handling series, today we're taking a hard look at the JSON Parse...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yawkat Fair enough. Originally I had aversion to unnecessary traversal beyond needed tokens. But that’s probably not much of an argument. Could you please file a separate feature request (issue) for changing
FAIL_ON_TRAILING_TOKENS
default value for Jackson 3.0? That way I can close this issue.Closing as I do not consider it a bug & there is the follow-up issue of possibly changing the default behavior.