-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Description
- Describe the feature in as much detail as possible.
Given a json object of any primitive type, I'd like to be able to call something like std::to_string on it, allowing me to turn it into a string without the quotes/escaping that dump would put on a string.
So far the closest I've gotten to the behavior I want is a big switch statement on the type of the json object, where I call std::to_string(json_val.get<thetype>()) in each case except string and raise an exception on non-primitive types.
So if I have the object { 'lokey' : 'hival' }, I want to be able to save the string "hival" (where the quotes ust denote the string, in memory would just be hival) and not "\"hival\"". I would like the same function to implicitly format bools and ints to strings, as well. I understand that this is asking for opinionated behavior, but I think it would be helpful for brevity if you were, for example, converting from one JSON schema to another, where the same thing has a different type in the two schema. At the least, letting me get just the string of a string value instead of the escaped version would be enough for me.
I'm very sorry if there's already something like this in the library, I looked through the documentation multiple times over the last few days before arriving at my switch statement.
Thanks for the awesome library!