Fix exception during ingestion

This commit is contained in:
frank chen 2021-09-19 12:28:24 +08:00
parent fa8ffe96d3
commit 5a5484b9ea
1 changed files with 9 additions and 12 deletions

View File

@ -86,7 +86,14 @@ public class JSONFlattenerMaker implements ObjectFlatteners.FlattenerMaker<JsonN
public Function<JsonNode, Object> makeJsonPathExtractor(final String expr)
{
final JsonPath jsonPath = JsonPath.compile(expr);
return node -> valueConversionFunction(jsonPath.read(node, JSONPATH_CONFIGURATION));
return node -> {
Object val = jsonPath.read(node, JSONPATH_CONFIGURATION);
if (val instanceof JsonNode) {
return valueConversionFunction((JsonNode) val);
} else {
return val;
}
};
}
@Override
@ -115,17 +122,7 @@ public class JSONFlattenerMaker implements ObjectFlatteners.FlattenerMaker<JsonN
}
@Nullable
private Object valueConversionFunction(Object val)
{
if (val instanceof JsonNode) {
return convertJsonNode((JsonNode) val);
} else {
return val;
}
}
@Nullable
private Object convertJsonNode(JsonNode val)
private Object valueConversionFunction(JsonNode val)
{
if (val == null || val.isNull()) {
return null;