davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.02k stars 250 forks source link

Handle array got from json using onion_* functions? #241

Closed alexe100 closed 5 years ago

alexe100 commented 5 years ago

Hi! I am trying to handle json data on onion-based rest server.

In a situation where client posts a regular json object e.g {"xxx":"yyy"} the following code works well: ... onion_dict jreq = onion_dict_from_json(onion_block_data(dreq));
char
pchTemp=onion_dict_get(jreq,"xxx"); if(pchTemp) strncpy(strX,pchTemp,64);

However, in a situation where client posts something like:

{"rec":[{"xxx":"yyy"},{"www":"yyy"}]} I can not find the way

to iterate the array got from json. How to handle this using onion functions (or not)?

Thanks a lot

Alex

davidmoreno commented 5 years ago

JSON support in Onion is VERY limited. AFAIR it does not have support for lists.

If you really need JSON support, I suggest you use other library for parsing and manipulation.

alexe100 commented 5 years ago

Right! Thanks