json icon indicating copy to clipboard operation
json copied to clipboard

Explore string <--> number conversion

Open vinniefalco opened this issue 4 years ago • 3 comments

value_to (and number_cast) could convert string to integer. And we could have a free function that changes a value to a string if the number is outside +/- 2^53. This should be explored first.

vinniefalco avatar Sep 28 '20 15:09 vinniefalco

string::to_number could become a thing, given Charconv dependency.

json::string js = "123";
auto n = js.to_number<int>();

Another question if we then want to add this converstion to value::to_number.

grisumbras avatar Apr 08 '24 14:04 grisumbras

I think the idea here is that it would be easier for people who want numbers represented as strings in their JSON. I would just close this and let users ask for it.

vinniefalco avatar Apr 09 '24 19:04 vinniefalco

I vaguely remember that someone actually asked for this, but I can't find an issue, so it probably was a conversation on Slack. @madmongo1, was that you?

grisumbras avatar Apr 11 '24 18:04 grisumbras