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 fails when number literals start with zero #1820

Closed
Haddy1 opened this issue Oct 30, 2019 · 1 comment
Closed

Parse fails when number literals start with zero #1820

Haddy1 opened this issue Oct 30, 2019 · 1 comment
Labels
solution: invalid the issue is not related to the library

Comments

@Haddy1
Copy link

Haddy1 commented Oct 30, 2019

  • What is the issue you have?
    Parsing fails for number literals beginning with "0", e.g. time stamps

Program crashes with following Error:
terminate called after throwing an instance of 'nlohmann::detail::parse_error'
what(): [json.exception.parse_error.101] parse error at line 1, column 16: syntax error while parsing object - unexpected number literal; expected '}'

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    auto j = "{ \"time\": 080000 }"_json;

  • What is the expected behavior?
    "080000" should be parsed as a numeral

  • And what is the actual behavior instead?
    Program crashes with error message:
    terminate called after throwing an instance of 'nlohmann::detail::parse_error'
    what(): [json.exception.parse_error.101] parse error at line 1, column 16: syntax error while parsing object - unexpected number literal; expected '}'

  • Which compiler and operating system are you using? Is it a supported compiler?
    gcc (Debian 6.3.0-18+deb9u1)

  • Did you use a released version of the library or the version from the develop branch?
    Using Release 3.7.0

@nlohmann
Copy link
Owner

Numbers starting with 0 and not immediately followed by ., e, E, or whitespace are not allowed in JSON:

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels Oct 30, 2019
@nlohmann nlohmann closed this as completed Nov 1, 2019
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

2 participants