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

Is there a current way to represent strings as json int? #1503

Closed
Trevinlc1997 opened this issue Mar 6, 2019 · 3 comments
Closed

Is there a current way to represent strings as json int? #1503

Trevinlc1997 opened this issue Mar 6, 2019 · 3 comments
Labels
solution: proposed fix a fix for the issue has been proposed and waits for confirmation state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@Trevinlc1997
Copy link

Trevinlc1997 commented Mar 6, 2019

The title may be pretty unspecific but what I am wanting is to give json the string value but without the quotes. (I am not saying for all string values, just ones I ask nlohmann::json to drop the quotes for)
Example: {"Voltage" : "15"} would instead be {"Voltage" : 15}

Now you may be questioning why not just use a int, etc. But the problem arises when I insert a double. I want to only display two numbers after the decimal spot. What my plan was;was insert the number into a string, cut the string after the two decimal spots and then ask nlohmann::json to represent that string as a number.

Here's an example of why I am asking to represent a string as number
What happens: {"Voltage" : 15.430000000001}
What I want: {"Voltage" : 15.43}

@nickaein
Copy link
Contributor

nickaein commented Mar 6, 2019

This is relevant to #1421. Probably a duplicate?

@nlohmann
Copy link
Owner

This could be solved like in #1384.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Mar 10, 2019
@stale
Copy link

stale bot commented Apr 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Apr 9, 2019
@stale stale bot closed this as completed Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: proposed fix a fix for the issue has been proposed and waits for confirmation state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

3 participants