mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-13 05:43:04 +00:00
Warn during json-tool extraction if the extracted field isn't found
This commit is contained in:
parent
b6163dd435
commit
2b1cba0b53
10
jsontool.cpp
10
jsontool.cpp
@ -138,9 +138,11 @@ std::string sort_quote(const char *s) {
|
||||
void out(std::string const &s, int type, json_object *properties) {
|
||||
if (extract != NULL) {
|
||||
std::string extracted = sort_quote("null");
|
||||
bool found = false;
|
||||
|
||||
json_object *o = json_hash_get(properties, extract);
|
||||
if (o != NULL) {
|
||||
found = true;
|
||||
if (o->type == JSON_STRING || o->type == JSON_NUMBER) {
|
||||
extracted = sort_quote(o->string);
|
||||
} else {
|
||||
@ -153,6 +155,14 @@ void out(std::string const &s, int type, json_object *properties) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
static bool warned = false;
|
||||
if (!warned) {
|
||||
fprintf(stderr, "Warning: extract key \"%s\" not found in JSON\n", extract);
|
||||
warned = true;
|
||||
}
|
||||
}
|
||||
|
||||
printf("{\"%s\":%s}\n", extracted.c_str(), s.c_str());
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user