File src/yajl/yajl_tree.h

Parses JSON data and returns the data in tree form.
Writtan by Florian Forster
August 2010
This interface makes quick parsing and extraction of smallish JSON docs trivial, as shown in the following example:
example/parse_config.c

Included in: example/parse_config.c
  src/yajl_tree.c

Included Files


Typedef yajl_type

possible data types that a yajl_val_s can hold

typedef enum {...} yajl_type

enum  
   {  
      yajl_t_string;  
      yajl_t_number;  
      yajl_t_object;  
      yajl_t_array;  
      yajl_t_true;  
      yajl_t_false;  
      yajl_t_null;  
      yajl_t_any; The <any> type isn't valid for yajl_val_s.type, but can be used as an argument to routines like yajl_tree_get().
   }  

Typedef yajl_val

A pointer to a node in the parse tree

typedef struct yajl_val_s* yajl_val

See: Type struct yajl_val_s

Type struct yajl_val_s

A JSON value representation capable of holding one of the seven types above. For "string", "number", "object", and "array" additional data is available in the union. The "YAJL_IS_*" and "YAJL_GET_*" macros below allow type checking and convenient value extraction.

struct yajl_val_s

struct yajl_val_s  
   {  
      yajl_type type; Type of the value contained. Use the "YAJL_IS_*" macros to check for a specific type.
      union  
        {  
            char* string;  
            struct  
             {  
                  long long i; integer value, if representable.
                  double d; double value, if representable.
                  char* r; unparsed number in string form.
                  unsigned int flags; Signals whether the \em i and \em d members are valid. See \c YAJL_NUMBER_INT_VALID and \c YAJL_NUMBER_DOUBLE_VALID.
             }  
          number;  
            struct  
             {  
                  const char** keys; Array of keys
                  yajl_val* values; Array of values.
                  size_t len; Number of key-value-pairs.
             }  
          object;  
            struct  
             {  
                  yajl_val* values; Array of elements.
                  size_t len; Number of elements.
             }  
          array;  
        }  
     u;  
   }