jansson icon indicating copy to clipboard operation
jansson copied to clipboard

Feature request: format character 'a' to return arrays from json_unpack

Open DanielT opened this issue 14 years ago • 2 comments

Currently I'm writing lots of code that looks like this: if (json_unpack(input, "{so!}", "some_array", &the_array) == -1 || !json_is_array(the_array)) { /* error handling code */ }

I would like to be able to use 'a' in place of the 'o' and not have to check if the returned json_t is an array or not.

DanielT avatar Jan 03 '12 22:01 DanielT

Sounds like a sensible idea. But if a format character for array is added, one should also be added for object, and both "o" and "O" are already taken :(

akheron avatar Jan 05 '12 07:01 akheron

I would also like to ask for implementing this feature... with "objects in objects" I can already do this with nested curly brackets, e.g. "{ss s{ss}}", but this is not possible for arrays with an unknown length (which are quite common). There normally is no "variable length object" (object with an unknown number of keys).

HRogge avatar Sep 16 '20 13:09 HRogge