GitHub user joemeszaros opened a pull request:
https://github.com/apache/nifi/pull/88
NIFI 945: New property (wrap as array) in avro2json converter
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 an array of
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 tracking events
```({"id":"user1", "item":"itemX", "action": "buy"}, {"id":"user2",
"item":"itemY", "action": "like"})...{"id":"userN", ...})```.
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.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ImpressTV/nifi NIFI-945
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/88.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #88
----
commit 75dce9c1ed1018cc14562478fd83d727501700d3
Author: Joe <[email protected]>
Date: 2015-09-09T08:40:15Z
New property (wrap as array) in avro2json converter
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 intances to a target component (e.g. Kafka).
Let's assume you have an Avro content as stream of records (record1,
record2, ...). If wrap as array is false, the converter will expose the records
as sequence of single JSON objects:
record1
record2
...
recordN
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:
[record1,record2,...,recordN]
It is useful when you want to convert your Avro content to a valid JSON
array.
commit 96d6c1cc13e15c2467eb0216668eb5e18a7d48af
Author: Joe <[email protected]>
Date: 2015-09-10T11:53:25Z
NIFI 945: Test new property in avro2json converter
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---