plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

json.h (556B)


      1 AUTOLIB(json)
      2 
      3 typedef enum {
      4 	JNone,
      5 	JNum,
      6 	JStr = 1 << 1,
      7 	JObj = 1 << 2,
      8 	JErr = 1 << 3
      9 } JsonType;
     10 
     11 typedef union {
     12 	String s;
     13 	double n;
     14 	char c;
     15 } JsonVal;
     16 
     17 typedef struct {
     18 	String k;
     19 	JsonVal v;
     20 	JsonType t;
     21 } JsonObj;
     22 
     23 typedef struct {
     24 	ulong st[8];   /*obj stack*/
     25 	JsonObj* o;    /*obj vector*/
     26 	JsonObj* cur;  /*cur obj*/
     27 	ulong n;       /*stack number*/
     28 
     29 	/* don't use these */
     30 	String s;   /*data buffer*/
     31 	ulong pos;  /*buffer pos*/
     32 } Json;
     33 
     34 void json_close(Json *j);
     35 int json_init(Json *j, char *file);
     36 int json_next(Json *j, JsonType t);