2014-02-06 05:27:48 +00:00
|
|
|
typedef enum json_type {
|
2014-02-06 06:40:35 +00:00
|
|
|
JSON_HASH, JSON_ARRAY, JSON_NUMBER, JSON_STRING, JSON_TRUE, JSON_FALSE, JSON_NULL,
|
2014-02-06 05:27:48 +00:00
|
|
|
} json_type;
|
|
|
|
|
|
|
|
typedef struct json_object {
|
|
|
|
json_type type;
|
|
|
|
struct json_object *parent;
|
|
|
|
|
|
|
|
char *string;
|
|
|
|
double number;
|
2014-02-06 07:18:27 +00:00
|
|
|
|
|
|
|
struct json_object **array;
|
|
|
|
struct json_object **keys;
|
|
|
|
struct json_object **values;
|
|
|
|
int length;
|
2014-02-07 02:56:22 +00:00
|
|
|
|
|
|
|
int expect;
|
2014-02-06 05:27:48 +00:00
|
|
|
} json_object;
|
|
|
|
|
2014-02-07 02:56:22 +00:00
|
|
|
struct json_pull {
|
2014-02-07 05:06:27 +00:00
|
|
|
json_object *root;
|
2014-02-07 02:56:22 +00:00
|
|
|
char *error;
|
2014-02-07 03:22:37 +00:00
|
|
|
|
|
|
|
int (*read)(struct json_pull *);
|
|
|
|
int (*peek)(struct json_pull *);
|
|
|
|
void *source;
|
2014-02-07 04:44:39 +00:00
|
|
|
int line;
|
2014-02-07 05:06:27 +00:00
|
|
|
|
|
|
|
json_object *container;
|
2014-02-07 02:56:22 +00:00
|
|
|
};
|
|
|
|
typedef struct json_pull json_pull;
|
|
|
|
|
2014-02-07 03:22:37 +00:00
|
|
|
json_pull *json_begin_file(FILE *f);
|
2014-02-07 03:27:21 +00:00
|
|
|
json_pull *json_begin_string(char *s);
|
2014-02-07 02:56:22 +00:00
|
|
|
json_object *json_parse(json_pull *j);
|
2014-02-07 06:45:40 +00:00
|
|
|
void json_free(json_object *j);
|
2014-02-07 02:56:22 +00:00
|
|
|
|
2014-02-06 05:27:48 +00:00
|
|
|
json_object *json_hash_get(json_object *o, char *s);
|