String to array
tpolekhin opened this issue · 2 comments
tpolekhin commented
Hello, is there any way to convert string
or char []
to an array of ASCII codes in JSON?
The only example with array that i found uses parse
from "[1, true, \"text\"]"
to create an array.
Something like this:
{
"example_string": "abc",
"example_array": [61, 62, 63]
}
Thanks!
kazuho commented
Hello, is there any way to convert
string
orchar []
to an array of ASCII codes in JSON?
No method that does that is provided, but you can do it, for example, by:
- create
picojson::value
of an array type (i.e.picojson::value v(picojson::array())
) - push elements to the value (i.e.
v.get<picojson::array>().push_back(ch)
) - convert the value to JSON
tpolekhin commented
That helped, thanks!