mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Slightly less wordy name for reading JSON with separators
This commit is contained in:
@@ -59,4 +59,10 @@ Reading JSON streams with callbacks
|
|||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
If you are outputting a new stream as you read instead of just looking for the
|
If you are outputting a new stream as you read instead of just looking for the
|
||||||
sub-objects that interest you,
|
sub-objects that interest you, you also need to know when arrays and hashes begin,
|
||||||
|
not just when they end, so you can output the opening bracket or brace. For this
|
||||||
|
purpose there is an additional streaming reader function,
|
||||||
|
<code>json_read_separators()</code>, which takes an additional argument for
|
||||||
|
a function to call when brackets, braces, commas, and colons are read.
|
||||||
|
Other object types and the closing of arrays and hashes are still sent through
|
||||||
|
the normal return value.
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void process_callback(FILE *f, char *fname) {
|
|||||||
json_object *j;
|
json_object *j;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
|
|
||||||
while ((j = json_read_with_separators(jp, callback, &level)) != NULL) {
|
while ((j = json_read_separators(jp, callback, &level)) != NULL) {
|
||||||
json_print_one(j, &level);
|
json_print_one(j, &level);
|
||||||
json_free(j);
|
json_free(j);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -175,7 +175,7 @@ static void string_free(struct string *s) {
|
|||||||
free(s->buf);
|
free(s->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object *json_read_with_separators(json_pull *j, json_separator_callback cb, void *state) {
|
json_object *json_read_separators(json_pull *j, json_separator_callback cb, void *state) {
|
||||||
int c;
|
int c;
|
||||||
again:
|
again:
|
||||||
/////////////////////////// Whitespace
|
/////////////////////////// Whitespace
|
||||||
@@ -476,7 +476,7 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
json_object *json_read(json_pull *j) {
|
json_object *json_read(json_pull *j) {
|
||||||
return json_read_with_separators(j, NULL, NULL);
|
return json_read_separators(j, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
json_object *json_read_tree(json_pull *p) {
|
json_object *json_read_tree(json_pull *p) {
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ typedef void (*json_separator_callback)(json_type type, json_pull *j, void *stat
|
|||||||
|
|
||||||
json_object *json_read_tree(json_pull *j);
|
json_object *json_read_tree(json_pull *j);
|
||||||
json_object *json_read(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);
|
json_object *json_read_separators(json_pull *j, json_separator_callback cb, void *state);
|
||||||
void json_free(json_object *j);
|
void json_free(json_object *j);
|
||||||
|
|
||||||
json_object *json_hash_get(json_object *o, char *s);
|
json_object *json_hash_get(json_object *o, char *s);
|
||||||
|
|||||||
Reference in New Issue
Block a user