Closed goodguysoft closed 1 year ago
The JSON structure is correct, but the payload in postData
is invalid Unicode (hence the error message). The JSON specification (RFC 8259) assumes correct Unicode to ensure interoperability. The specification allows implementations to reject inputs otherwise. The library currently has no switch to ignore such an error.
(Are all your inputs illformed like this or is this an exception?)
postData
is actual post data created by website; it may be binary, and in Chrome DevTools Protocol they for any reason just encode it in such a way; may be base64 is better choice here, but in Google they decided to just escape binary data I suppose. So, wrong data may appear periodically dependently on website that I try to debug with Chrome DevTools. The only way how to fix it for now I see is to filter out postData
value and later parse it manually somehow. May be any "incorrect string" callback that will contain the wrong string (postData
value in such example) and allow to parse it with custom code is good idea, similar to current parser_callback_t
callback, but as I see this callback doesn't allow to handle wrong data.
Description
The library throws exception when I try to parse JSON message produced by Chrome browser via Chrome DevTools protocol. I have no idea whether Chrome breaks any standards or not, but Chrome is standard de-facto, so at least any flag that will make the library compatible with Chrome may be good idea. I also can visualize the JSON with Visual Studio, Notepad++ and some other tools, so this format is OK for other widely used tools.
Reproduction steps
I add the code sample (Visual Studio 2022 native unit test). I just call
json::parse
for some JSON file generated by Chrome browser.Expected vs. actual results
I expect that if Chrome, Visual Studio, Notepad++ can parse the JSON,
nlohmann::json
should also supply a way to do so. You can download the file that contains target JSON here: data.jsonMinimal code example
Error messages
Compiler and operating system
Visual Studio 2022, Windows 11 Pro.
Library version
3.11.2
Validation
develop
branch is used.