use of org.hisp.dhis.jsontree.JsonValue in project dhis2-core by dhis2.
the class H2SqlFunction method jsonb_extract_path_text.
// Postgres inbuilt function
public static String jsonb_extract_path_text(PGobject json, String... paths) {
try {
String content = json.getValue();
if (content == null) {
return null;
}
JsonValue value = new JsonResponse(content).get(toJsonPath(paths));
if (!value.exists()) {
return null;
}
if (value.node().getType() == JsonNodeType.STRING) {
return value.as(JsonString.class).string();
}
return value.node().getDeclaration();
} catch (Exception e) {
log.error("Failed to extract path", e);
throw e;
}
}
use of org.hisp.dhis.jsontree.JsonValue in project dhis2-core by dhis2.
the class H2SqlFunction method jsonb_extract_path.
// Postgres inbuilt function
public static String jsonb_extract_path(PGobject json, String... paths) throws SQLException {
try {
String content = json.getValue();
if (content == null) {
return null;
}
JsonValue value = new JsonResponse(content).get(toJsonPath(paths));
if (!value.exists()) {
return null;
}
return value.node().getDeclaration();
} catch (Exception e) {
log.error("Failed to extract path", e);
throw e;
}
}
Aggregations