@Categories(categories={"parser","json"}) public class JsParser extends Object implements Directive, Lineage
| Constructor and Description |
|---|
JsParser() |
| Modifier and Type | Method and Description |
|---|---|
UsageDefinition |
define() |
void |
destroy() |
List<Row> |
execute(List<Row> rows,
ExecutorContext context) |
static Object |
getValue(com.google.gson.JsonElement element)
Gets a single value from the
JsonElement. |
static Object |
getValue(com.google.gson.JsonPrimitive primitive)
Extracts a value from the
JsonPrimitive. |
void |
initialize(Arguments args) |
static void |
jsonFlatten(com.google.gson.JsonObject root,
String field,
int depth,
int maxDepth,
Row row)
Recursively flattens JSON until the 'depth' is reached.
|
Mutation |
lineage() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCountMetricsgetOutputSchemapublic static final String NAME
public UsageDefinition define()
public void initialize(Arguments args) throws DirectiveParseException
initialize in interface Executor<List<Row>,List<Row>>DirectiveParseExceptionpublic List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException, ErrorRowException
execute in interface Executor<List<Row>,List<Row>>DirectiveExecutionExceptionErrorRowExceptionpublic static void jsonFlatten(com.google.gson.JsonObject root,
String field,
int depth,
int maxDepth,
Row row)
root - of the JSONObjectfield - name to be used to be stored in the row.depth - current depth into JSON structure.maxDepth - maximum depth to reachrow - to which the flatten fields need to be added.public static Object getValue(com.google.gson.JsonElement element)
JsonElement. The value could be
JsonObject or JsonArray or JsonPrimitive.element - value to be extracted.JsonNull.public static Object getValue(com.google.gson.JsonPrimitive primitive)
JsonPrimitive.primitive - object to extract real value.JsonPrimitiveCopyright © 2024 CDAP Licensed under the Apache License, Version 2.0.