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

Could the parser locate errors to line? #675

Closed
PinkGabriel opened this issue Aug 4, 2017 · 5 comments
Closed

Could the parser locate errors to line? #675

PinkGabriel opened this issue Aug 4, 2017 · 5 comments
Labels
kind: question solution: duplicate the issue is a duplicate; refer to the linked issue instead solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@PinkGabriel
Copy link

hello again~
I use the lib to parse a json file like this:

std::ifstream ifs(filename);
json json_input;
ifs >> json_input;

Then I use the json class to do things. But if the input file has syntax error, the parser just reports what the error is, without where the error happens. Is it possible to locate errors to exactly which line the error happens in the json file?
Thanks!

@nlohmann
Copy link
Owner

nlohmann commented Aug 4, 2017

Related: #301.

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Aug 4, 2017
@nlohmann
Copy link
Owner

nlohmann commented Aug 4, 2017

The location of parse errors is given in the version of the develop branch. It is unreleased code that will be released as version 3.0.0 later this year.

@nlohmann
Copy link
Owner

nlohmann commented Aug 4, 2017

Examples for the exception strings are

[json.exception.parse_error.101] parse error at 2: syntax error - invalid number; expected digit after '-'; last read: '--'

for an input like --1.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Aug 4, 2017
@PinkGabriel
Copy link
Author

Thanks for the reply!
Before asking I've searched the keyword locate but not location...Sorry for asking a same question..
I'll try the develop version, and hope the 3.0.0 everything goes well~~
thank you so much!

@nlohmann
Copy link
Owner

nlohmann commented Aug 4, 2017

No worries! If you need further assistance, just open an issue.

@nlohmann nlohmann closed this as completed Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: duplicate the issue is a duplicate; refer to the linked issue instead solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants