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

Quoted numbers #1538

Closed
chiumichael opened this issue Mar 22, 2019 · 1 comment
Closed

Quoted numbers #1538

chiumichael opened this issue Mar 22, 2019 · 1 comment
Labels
kind: question solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)

Comments

@chiumichael
Copy link

I hope this hasn't been asked before (i did try searching through past issues and SO for this), but I was wondering if the library offers some functionality to parse numbers in json files that are quoted, for e.g.

{"a" : "5"}

I tried something like int mynumber = j.at("a").get<int>() but i get a runtime error saying that it expected a string. Is there some other function to use or do i have to extract it as a string first and then convert it to an integer myself elsewhere?

Thanks!

@nlohmann
Copy link
Owner

nlohmann commented Mar 22, 2019

No, this is nothing the library does out of the box. You would need to call code like

foo["a"] = std:: stoi(foo["a"]);

yourself.

@nlohmann nlohmann added the solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope) label Mar 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)
Projects
None yet
Development

No branches or pull requests

2 participants