Get rid of root node to simplify. Walk the tree if you need it.

This commit is contained in:
Eric Fischer 2014-02-07 16:56:38 -08:00
parent e99c037be3
commit 0fd66048c8
2 changed files with 6 additions and 9 deletions

View File

@ -10,7 +10,6 @@ json_pull *json_begin(int (*read)(struct json_pull *), int (*peek)(struct json_p
j->error = NULL;
j->line = 1;
j->root = NULL;
j->container = NULL;
j->read = read;
@ -123,8 +122,6 @@ static json_object *add_object(json_pull *j, json_type type) {
return NULL;
}
}
} else {
j->root = o;
}
return o;

View File

@ -24,8 +24,7 @@ typedef struct json_object {
int expect;
} json_object;
struct json_pull {
json_object *root;
typedef struct json_pull {
char *error;
int (*read)(struct json_pull *);
@ -34,15 +33,16 @@ struct json_pull {
int line;
json_object *container;
};
typedef struct json_pull json_pull;
typedef void (*json_separator_callback)(json_type type, json_pull *j, void *state);
} json_pull;
json_pull *json_begin_file(FILE *f);
json_pull *json_begin_string(char *s);
json_pull *json_begin(int (*read)(struct json_pull *), int (*peek)(struct json_pull *), void *source);
void json_end(json_pull *p);
typedef void (*json_separator_callback)(json_type type, json_pull *j, void *state);
json_object *json_read_tree(json_pull *j);
json_object *json_read(json_pull *j);
json_object *json_read_with_separators(json_pull *j, json_separator_callback cb, void *state);
void json_free(json_object *j);