kazuho/picojson

String to array

tpolekhin opened this issue · 2 comments

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!

Hello, is there any way to convert string or char [] to an array of ASCII codes in JSON?

No method that does that is provided, but you can do it, for example, by:

  1. create picojson::value of an array type (i.e. picojson::value v(picojson::array()))
  2. push elements to the value (i.e. v.get<picojson::array>().push_back(ch))
  3. convert the value to JSON

That helped, thanks!