Problems to detect arrays in JSON files using YAJL trees in C -


I try to parse JSON file using jajl 2.0.4 (using yajl_tree.h) , But I have a problem finding out whether the value found is an array or not (even if I use YAJL_IS_ARRAY, it seems that the type field is not set.

Here is my JSON file: <">" device ": [" name ":" minoid "," type ":" node "," attribute ": [{" name ":" cpu_available "," Value ":" 8 "}, {" name ":" in this code :

  const char * path [] = {"tool", (const char *)}; yajl_val v = yajl_tree_get (node, path, yajl_t_array); if (v & amp; YAJL_IS_ARRAY (v)) {for (i = 0; i & lt; v- & gt; u.array.len; i ++) {yajl_val obj = v-> u.array.values ​​[i] ; If (obj & amp; yajl_IS_ARRAY (obje)) {for (j = 0; j & lt; obj-> u.object.len; j ++) {yajl_val obj2 = obj-> .array.values ​​[j]; if (obj2 & amp; yaajl_IS_ARRAY (obj2)) {for (k = 0; k & lt; obj2- & gt; U.array.len; K ++) {yajl_val obj3 = obj- & gt; U.array.values ​​[k]; Const char * key3 = obj3- & gt; U.object.keys [k]; Yajl_val val3 = obj3- & gt; U.object.values ​​[k]; Printf ("% s:% s \ n", key3, val3- & gt; u string); }} And {const char * key2 = obj- & gt; U.object.keys [j]; Yajl_val val2 = obj- & gt; U.object.values ​​[j]; Printf ("% s:% s \ n", key2, val2-> u.string); }}} And {const char * key = obj- & gt; U.object.keys [i]; Yajl_val val = obj- & gt; U.object.values ​​[i]; Printf ("% s:% s", key, Val- & gt; U string); }}}  

Even when I use this code, I do not enter YAJL_IS_ARRAY even if the value is an array, for example the attribute I was wondering if YAJL_IS_ARRAY one If the array is not right to receive, then what should be used? Also, is it normal that there is no right type of my objects (obj, obj2 ...)? What did i mistake

Thank you in advance for your help :)

Your JSON is not an array This is a key with a key "device", and the value of "device" is an array. In this situation, an array containing a dictionary is


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -