Skip to content

How can I detect that an input stream contains an incomplete json #4347

Answered by nlohmann
jpgaribotti asked this question in Q&A
Discussion options

You must be logged in to vote

You could check the id member of the parse_error exception to be 110 which is the code for general parse errors including the "unexpected end of input". Then you could also check the byte member which indicates the error position. This should point to the last byte of the input in case of an "unexpected end of input" error.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jpgaribotti
Comment options

Answer selected by jpgaribotti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants