mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-05 10:09:08 +00:00
Break up the wall of text a little
This commit is contained in:
parent
e195aa54c3
commit
8aec0ed9d2
20
json.c
20
json.c
@ -106,6 +106,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/////////////////////////// Whitespace
|
||||
|
||||
while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
|
||||
c = getc(f);
|
||||
if (c == EOF) {
|
||||
@ -113,6 +115,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////// Arrays
|
||||
|
||||
if (c == '[') {
|
||||
return json_parse(f, add_object(JSON_ARRAY, current));
|
||||
} else if (c == ']') {
|
||||
@ -123,6 +127,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return current->parent;
|
||||
}
|
||||
|
||||
/////////////////////////// Hashes
|
||||
|
||||
if (c == '{') {
|
||||
return json_parse(f, add_object(JSON_HASH, current));
|
||||
} else if (c == '}') {
|
||||
@ -133,6 +139,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return current->parent;
|
||||
}
|
||||
|
||||
/////////////////////////// Null
|
||||
|
||||
if (c == 'n') {
|
||||
if (getc(f) != 'u' || getc(f) != 'l' || getc(f) != 'l') {
|
||||
json_error("misspelled null\n");
|
||||
@ -141,6 +149,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return add_object(JSON_NULL, current);
|
||||
}
|
||||
|
||||
/////////////////////////// True
|
||||
|
||||
if (c == 't') {
|
||||
if (getc(f) != 'r' || getc(f) != 'u' || getc(f) != 'e') {
|
||||
json_error("misspelled true\n");
|
||||
@ -149,6 +159,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return add_object(JSON_TRUE, current);
|
||||
}
|
||||
|
||||
/////////////////////////// False
|
||||
|
||||
if (c == 'f') {
|
||||
if (getc(f) != 'a' || getc(f) != 'l' || getc(f) != 's' || getc(f) != 'e') {
|
||||
json_error("misspelled false\n");
|
||||
@ -157,6 +169,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return add_object(JSON_FALSE, current);
|
||||
}
|
||||
|
||||
/////////////////////////// Comma
|
||||
|
||||
if (c == ',') {
|
||||
if (current->parent == NULL ||
|
||||
(current->parent->type != JSON_ARRAY &&
|
||||
@ -167,6 +181,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return json_parse(f, current->parent);
|
||||
}
|
||||
|
||||
/////////////////////////// Colon
|
||||
|
||||
if (c == ':') {
|
||||
if (current->parent == NULL || current->parent->type != JSON_HASH) {
|
||||
json_error(": not in hash\n");
|
||||
@ -178,6 +194,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return json_parse(f, current->parent);
|
||||
}
|
||||
|
||||
/////////////////////////// Numbers
|
||||
|
||||
if (c == '-' || (c >= '0' && c <= '9')) {
|
||||
struct string val;
|
||||
string_init(&val);
|
||||
@ -232,6 +250,8 @@ json_object *json_parse(FILE *f, json_object *current) {
|
||||
return n;
|
||||
}
|
||||
|
||||
/////////////////////////// Strings
|
||||
|
||||
if (c == '"') {
|
||||
struct string val;
|
||||
string_init(&val);
|
||||
|
Loading…
x
Reference in New Issue
Block a user