Converts a Binary Avro record into a JSON object. This processor provides a direct mapping of an Avro field to a JSON field, such that the resulting JSON will have the same hierarchical structure as the Avro document. Note that the Avro schema information will be lost, as this is not a translation from binary Avro to JSON formatted Avro. The output JSON is encoded the UTF-8 encoding. If an incoming FlowFile contains a stream of multiple Avro records, the resultant FlowFile will contain a JSON Array containing all of the Avro records or a sequence of JSON Objects. If an incoming FlowFile does not contain any records, an empty JSON object is the output. Empty/Single Avro record FlowFile inputs are optionally wrapped in a container as dictated by ‘Wrap Single Record’
avro, convert, json
In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values.
|Name||Default Value||Allowable Values||Description|
|JSON container options||array||
|Determines how stream of records is exposed: either as a sequence of single Objects (none) (i.e. writing every Object to a new line), or as an array of Objects (array).|
|Wrap Single Record||false||
|Determines if the resulting output for empty records or a single record should be wrapped in a container array as specified by 'JSON container options'|
|failure||A FlowFile is routed to this relationship if it cannot be parsed as Avro or cannot be converted to JSON for any reason|
|success||A FlowFile is routed to this relationship after it has been converted to JSON|
|mime.type||Sets the mime type to application/json|
How to configure?
Step 1: Drag and drop the ConvertAvroToJSON processor to canvas.
Step 2: Double click the processor to configure. The configuration dialog will be opened as follows:
Step 3: Check the usage of each property and update those values.
Properties and usage
JSON container options: Used to specify how to convert the record either by sequence of object or array of object.
Wrap Single Record: Used to determine if the resulting output for empty records or a single record should be wrapped in a container array as specified by ‘JSON container options’.
Avro schema: Used to specify avro schema if avro records do not contain the schema.
For example, to read a database file and convert it into json, you can use ConvertAvroToJSON processor.