How to get string value from a number? #3432
-
Output:
Question> Is there a way that I can get the original number's string value(i.e. "3.1410")? If the current version doesn't support this, is there a hack I can do? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I suggest you take a look at https://json.nlohmann.me/api/json_sax/number_float/. Using the SAX-style parser gives you access to the original string. You can then store or process it as you see fit. |
Beta Was this translation helpful? Give feedback.
-
Question> Is it true that I have to manually parse the returned values after I switch to using the SAX interface? For example,
Basically, I have to build a parser to parse the If that is the case, then this is not what I really wanted to do. |
Beta Was this translation helpful? Give feedback.
-
Explained in the function documentation:
|
Beta Was this translation helpful? Give feedback.
I suggest you take a look at https://json.nlohmann.me/api/json_sax/number_float/.
Using the SAX-style parser gives you access to the original string. You can then store or process it as you see fit.