-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parse error #3403
Comments
I think there should be a switch. Sometimes I just wanna store the literal string into the object string. I don't care wheather it's a valid UTF8 string or not. |
For reference, this is the exception:
The text describes it: the input is invalid UTF-8. The library is strict about this, as the JSON standard requires it. |
No, It's not a exception. i mean I put that invalid UTF8 string on purpose. Right now I just change the code which deal with the unicode string as |
I do not understand what you mean. Can you please explain in detail what you tried, what happened, and what you would have expected. |
Actually this is a part of the report of Cuckoo sandbox. You know that many people would store binary data as unicode format in json. Not all of them are readable or resolvable so I think there should be a switch or something to disable unicode string parsing. I think this would make nlohmann/json the best. Right now I do things very stupid like this: change line 6721 to: I cann't upload pics sorry. |
So then your original issue remains that the library throws a parse error in case of invalid UTF-8, right? The library supports multiple binary formats (https://json.nlohmann.me/features/binary_formats/) which in turn support binary values (https://json.nlohmann.me/features/binary_values/). |
No, The file I tried to parse is just json format plain text. But just part of this json contains invalid utf8 string. |
Understood. But then your file is invalid JSON, hence the exception. |
Ahh, No. the file was produced by python program. In python they are valid and work well. In python the \u prefix means unicode string and it can contain all possible value from 0x0000 to 0xffff without any restrictions. So I think this project may have the same behavior as Python program do. |
Right now I've got no time but later I can do some modification to the function json::parse and add new parameters to choice whether parse utf8 string to literal string or not. May I do a pull request later? |
That doesn't mean that it created valid JSON. That just means that it created something that it could understand. |
But actually this is the case. You don't know the encoding of the value. for example: |
oops, hard encode causes exception: |
The library supports only UTF-8, see https://json.nlohmann.me/home/faq/#parse-errors-reading-non-ascii-characters |
What is the issue you have?
some json string are well formated but just because it contain unreadable data,it was unable to parse.
Please describe the steps to reproduce the issue.
js.parse("{"key_name": "\udd281\u00c4(\u3ca3\u7724\u114a\u7722"}");
this cannot work well when the keyname is just above. not a error. this work well in python json.loads function.
Can you provide a small but working code example?
js.parse("{"key_name": "\udd281\u00c4(\u3ca3\u7724\u114a\u7722"}");
What is the expected behavior?
just load it to json value
And what is the actual behavior instead?
it reports error.
Which compiler and operating system are you using?
Visual Studio 2019
Which version of the library did you use?
develop
branchIf you experience a compilation error: can you compile and run the unit tests?
The text was updated successfully, but these errors were encountered: