Skip to content
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 on known good json file #551

Closed
AnthonyScaglione opened this issue Apr 8, 2017 · 4 comments
Closed

Parse error on known good json file #551

AnthonyScaglione opened this issue Apr 8, 2017 · 4 comments
Labels
solution: invalid the issue is not related to the library

Comments

@AnthonyScaglione
Copy link

AnthonyScaglione commented Apr 8, 2017

I am trying to test out this parser as I absolutely love the intuitive use of it, however I am having parse errors on a known (albeit huge) good json file.

using this code:

#include <iostream>
#include <json.hpp>
#include <fstream>
#include <iomanip>
using json = nlohmann::json;
int main()
{
    //read json file
    std::ifstream i("./rawjsondata/matches1.json");
    json j;
    i >> j;
    //write prettified json to another file
    std::ofstream o("./prettyrawjsondata/prettymatches1.json");
    o << std::setw(4) << j << std::endl;
}

on this json file

gives this error:

terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at 9467564: parse error - unexpected '"'

However, using a quick online json viewer, it gets correctly parsed

@jaredgrubb
Copy link
Contributor

Python can't load it either. It fails at byte 4173747 ('\xc3'):

'rName":"Pr\xc3\xb8t\xc3\xb8m\xc3\xa5n"'

Seems like it's not valid UTF8?

@nlohmann
Copy link
Owner

nlohmann commented Apr 8, 2017

I checked with the manual_lexer branch and got a more detailed warning:
[json.exception.parse_error.101] parse error at 9467566: syntax error - invalid string: not well-formed UTF-8 byte; last read '"\303?'

The problem is the byte sequence 0xc3 0x3f which is not well-formed. Byte 0xc3 must be followed by a byte from the range 0x80..0xbf.

@nlohmann
Copy link
Owner

nlohmann commented Apr 8, 2017

(Now I need to understand why Python even fails earlier...)

@nlohmann
Copy link
Owner

nlohmann commented Apr 8, 2017

I checked a bit more. The error is indeed a malformed string in line 50:

{"summonerId":38308286,"summonerName":"??irection"

As bytes

6d65 223a 22c3 3f69 7265 6374 696f 6e22  me":".?irection"

The byte sequence c3 3f is not well-formed.

@nlohmann nlohmann closed this as completed Apr 8, 2017
@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Apr 8, 2017
@nlohmann nlohmann mentioned this issue Apr 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

3 participants