From 0fd66048c888f2a6e9c4c03320b2b1400a0a3d17 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Fri, 7 Feb 2014 16:56:38 -0800 Subject: [PATCH] Get rid of root node to simplify. Walk the tree if you need it. --- jsonpull.c | 3 --- jsonpull.h | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/jsonpull.c b/jsonpull.c index c71a4351..aa2c8ed8 100644 --- a/jsonpull.c +++ b/jsonpull.c @@ -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; diff --git a/jsonpull.h b/jsonpull.h index 29173fa3..da5232bb 100644 --- a/jsonpull.h +++ b/jsonpull.h @@ -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);