Search in sources :

Example 1 with JsonUnflattener

use of com.github.wnameless.json.unflattener.JsonUnflattener in project auto-data-tokenize by GoogleCloudPlatform.

the class RecordUnflattener method unflatten.

/**
 * Returns an AVRO record by unflattening the FlatRecord through JSON unflattener.
 */
public GenericRecord unflatten(FlatRecord flatRecord) {
    Map<String, Object> jsonValueMap = Maps.newHashMap();
    for (Map.Entry<String, Value> entry : flatRecord.getValuesMap().entrySet()) {
        var valueProcessor = new ValueProcessor(entry);
        jsonValueMap.put(valueProcessor.cleanKey(), valueProcessor.convertedValue());
    }
    String unflattenedRecordJson = new JsonUnflattener(jsonValueMap).unflatten();
    return convertJsonToAvro(schema, unflattenedRecordJson);
}
Also used : JsonUnflattener(com.github.wnameless.json.unflattener.JsonUnflattener) Value(com.google.privacy.dlp.v2.Value) Map(java.util.Map)

Aggregations

JsonUnflattener (com.github.wnameless.json.unflattener.JsonUnflattener)1 Value (com.google.privacy.dlp.v2.Value)1 Map (java.util.Map)1