nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Mészáros (JIRA) <>
Subject [jira] [Created] (NIFI-945) New property (wrap as array) in avro2json converter
Date Thu, 10 Sep 2015 11:53:45 GMT
Joe Mészáros created NIFI-945:

             Summary: New property (wrap as array) in avro2json converter
                 Key: NIFI-945
             Project: Apache NiFi
          Issue Type: Improvement
          Components: Core Framework
            Reporter: Joe Mészáros
            Priority: Minor

Create a new property (wrap as array) in ConvertAvroToJson, which determines how stream of
records is exposed: either as a sequence of single Objects (false), writing every Object to
a new line, or as an array of Objects. Default value is true, meaning that the Avro content
is exposed as a sequence of root-level Object entries. False value is useful, when you want
to write your records as single instances to a target component (e.g. Kafka).

Let's assume you have an Avro content as stream of events ({"id":"user1", "item":"itemX",
"action": "buy"}, {"id":"user2", "item":"itemY", "action": "like"}). If wrap as array is false,
the converter will expose the records as sequence of single JSON objects:

{"id":"user1", "item":"itemX", "action": "buy"}
{"id":"user2", "item":"itemY", "action": "like"}
{"id":"userN", ...}

Please bear in mind, that the final output is not a valid JSON content. You can then forward
this content e.g. to Kafka, where every record will be a single Kafka message.

If wrap as array is true, the output looks like this:
[{"id":"user1", "item":"itemX", "action": "buy"},{"id":"user2", "item":"itemY", "action":
"like"},...,{"id":"userN", ...}]

It is useful when you want to convert your Avro content to a valid JSON array.

This message was sent by Atlassian JIRA

View raw message