Closed molsonkiko closed 9 months ago
Let's look at the error message you were getting more closely.
"Syntax error (severity = FATAL) at position nnn (char '}'): JSON Lines document does not contain exactly one JSON document per line"
The error you were getting talks about a JSON Lines document
because you were trying to use the JSON Lines parser to parse a regular JSON document. This is expected behavior (because when your document was pretty-printed, it was in fact not a valid JSON Lines document, even though it was valid JSON), and I would guess that the reason you thought your syntactically insignificant changes mattered was probably that you were unknowingly switching between using the Parse JSON Lines document
command and the Pretty-print current JSON file
command.
If the document you were working with had a .jsonl
extension, you were working with a JSON Lines document, and JSON Lines documents should not be pretty-printed because then they won't be JSON Lines documents any more.
There is no bug, everything is working as expected.
@JMoulding1958 Possible minor bug in JSON parser
Parser flags an error in valid(?) JSON string Steps to Reproduce the Issue
Open JSON file Format JSON file - works perfectly Parse JSON file: flags error:
"Syntax error (severity = FATAL) at position nnn (char '}'): JSON Lines document does not contain exactly one JSON document per line"
Expected Behavior
No error Actual Behavior
Error flagged with final curly bracket position Debug Information
This is the formatted JSON string that caused the error: { "results": { "message": "User does not exist||Invalid supply type", "status": "No Content", "code": 204, "requestid": "" } } The problem appears to lie with the "||" pipe characters in the message field pair value. If I remove or escape them, the parser no longer reports an error. I didn't think the pipe was a reserved character in JSON.
The parser error can also be removed by adding a trailing comma to the final field pair, like this: "requestid": "", }
Which is odd, as I believe the last field pair in any object within a JSON string should not have a trailing comma.
My assumptions re. correct JSON formatting may (of course) be completely wrong, hence the question mark in the title. If they are, then apologies for timewasting.
Thank you for such a brilliant product.
Cheers,
John