[ 
https://issues.apache.org/jira/browse/NIFI-945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14968237#comment-14968237
 ] 

ASF subversion and git services commented on NIFI-945:
------------------------------------------------------

Commit a5a5badb88311cb29cbe39088b57b9686314a1c6 in nifi's branch 
refs/heads/master from Joe
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=a5a5bad ]

NIFI-945 Create a new property (JSON Container) in ConvertAvroToJson, which 
determines how stream of records is exposed: either as a sequence of single 
Objects ("none"),
writing every Object to a new line, or as an array of Objects.

Let's assume you have an Avro content as stream of records (record1, record2, 
...). If JSON container is "none", 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 JSON container is "array", the output looks like this:

[record1,record2,...,recordN]

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

This closes #88

Reviewed and Amended (amendments reviewed by original patch author on github) 
by Tony Kurc ([email protected])


> New property (wrap as array) in avro2json converter
> ---------------------------------------------------
>
>                 Key: NIFI-945
>                 URL: https://issues.apache.org/jira/browse/NIFI-945
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Core Framework
>            Reporter: Joe Mészáros
>            Assignee: Tony Kurc
>            Priority: Minor
>              Labels: avro, improvement, json
>
> 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: 
> {noformat}({"id":"user1", "item":"itemX", "action": "buy"}, {"id":"user2", 
> "item":"itemY", "action": "like"}){noformat}
> If wrap as array is false, the converter will expose the records as sequence 
> of single JSON objects:
> {noformat}
> {"id":"user1", "item":"itemX", "action": "buy"}
> {"id":"user2", "item":"itemY", "action": "like"}
> ...
> {"id":"userN", ...}
> {noformat}
> 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:
> {noformat}
> [{"id":"user1", "item":"itemX", "action": "buy"},{"id":"user2", 
> "item":"itemY", "action": "like"},...,{"id":"userN", ...}]
> {noformat}
> It is useful when you want to convert your Avro content to a valid JSON array.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to