mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
The idea is that you can free any element once you are done with it, even if it is part of an array or hash that isn't completely read yet. Removing array elements is reasonably well defined because nothing else depends on them. Removing a hash key or value causes it to be replaced by a null unless the other side of the component has already been nulled out, in which case the whole pair is removed.
39 lines
776 B
C
39 lines
776 B
C
typedef enum json_type {
|
|
JSON_HASH, JSON_ARRAY, JSON_NUMBER, JSON_STRING, JSON_TRUE, JSON_FALSE, JSON_NULL,
|
|
} json_type;
|
|
|
|
typedef struct json_object {
|
|
json_type type;
|
|
struct json_object *parent;
|
|
|
|
char *string;
|
|
double number;
|
|
|
|
struct json_object **array;
|
|
struct json_object **keys;
|
|
struct json_object **values;
|
|
int length;
|
|
|
|
int expect;
|
|
} json_object;
|
|
|
|
struct json_pull {
|
|
json_object *root;
|
|
char *error;
|
|
|
|
int (*read)(struct json_pull *);
|
|
int (*peek)(struct json_pull *);
|
|
void *source;
|
|
int line;
|
|
|
|
json_object *container;
|
|
};
|
|
typedef struct json_pull json_pull;
|
|
|
|
json_pull *json_begin_file(FILE *f);
|
|
json_pull *json_begin_string(char *s);
|
|
json_object *json_parse(json_pull *j);
|
|
void json_free(json_object *j);
|
|
|
|
json_object *json_hash_get(json_object *o, char *s);
|