[ 
https://issues.apache.org/jira/browse/NIFI-5093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pierre Villard resolved NIFI-5093.
----------------------------------
    Resolution: Feedback Received

Apache NiFi 1.x is no longer maintained and no new release is planned on the 
1.x release line. Marking as resolved as part of a cleanup operation. Please 
open a new one with an updated description if this is still relevant for NiFi 
2.x.

> ConvertAvroToJson
> -----------------
>
>                 Key: NIFI-5093
>                 URL: https://issues.apache.org/jira/browse/NIFI-5093
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>         Environment: Ubuntu / Chromium
>            Reporter: Matt Forrester
>            Priority: Minor
>
> ConvertAvroToJson does not follow the expectations of anyone who knows JSON 
> or JavaScript when there are zero Avro records coming from upstream. For a 
> zero length sequence the outputs are:
>  
>     JSON Container Options: array
>      Wrap Single Record: false
>      Result: {}
>      Expected Result: ''
>      Why is this wrong?: This has not been wrapped in an array as specified 
> and in any no items were sent from upstream, not one item with zero fields
>  
>     JSON Container Options: array
>      Wrap Single Record: true
>      Result: [{}]
>      Expected Result: '[]'
>      Why is this wrong?: This is one item with no fields that was never sent 
> from the upstream.
>  
>     JSON Container Options: none
>      Wrap Single Record: false
>      Result: ''
>      Why is this wrong?: This is one item with no fields that was never sent 
> from the upstream.
>  
>     JSON Container Options: none
>      Wrap Single Record: true
>      Result: ''
>      Why is this wrong? This is one item with no fields that was never sent 
> from the upstream.
>  
> IMHO these options are specifying two things for what should actually be one 
> thing. In JSON, which is a subset of JavaScript an Object is represented as 
> {} and an Array is represented as [].
> If you have a stream of objects they could either:
>  * Be wrapped in `[]` and seperated by comma's making the whole document 
> valid JSON, for example `[]` or `[\{"name":"ben"},\{"name":"jane"}]`
>  * Formatted as NDJSON which would be `''` (0 bytes) or 
> `\{"name":"ben"}\n\{"name":"jane"}\n` where every line is valid JSON with a 
> final new line at the end.
>  
> UPDATE: Have created a new Processor which follows the NDJSON spec closer 
> with respect to new lines. The downstream SplitJSON seems much happier. It is 
> available at [https://github.com/forbesmyester/NiFi-ConvertAvroToClassicJSON] 
> .\{{}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to