mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 18:35:41 +02:00
Warn during json-tool extraction if the extracted field isn't found
This commit is contained in:
@@ -138,9 +138,11 @@ std::string sort_quote(const char *s) {
|
|||||||
void out(std::string const &s, int type, json_object *properties) {
|
void out(std::string const &s, int type, json_object *properties) {
|
||||||
if (extract != NULL) {
|
if (extract != NULL) {
|
||||||
std::string extracted = sort_quote("null");
|
std::string extracted = sort_quote("null");
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
json_object *o = json_hash_get(properties, extract);
|
json_object *o = json_hash_get(properties, extract);
|
||||||
if (o != NULL) {
|
if (o != NULL) {
|
||||||
|
found = true;
|
||||||
if (o->type == JSON_STRING || o->type == JSON_NUMBER) {
|
if (o->type == JSON_STRING || o->type == JSON_NUMBER) {
|
||||||
extracted = sort_quote(o->string);
|
extracted = sort_quote(o->string);
|
||||||
} else {
|
} 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());
|
printf("{\"%s\":%s}\n", extracted.c_str(), s.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user