[
https://issues.apache.org/jira/browse/NIFI-5093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Matt Forrester updated NIFI-5093:
---------------------------------
Description:
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 '[]', so the whole document is valid JSON, for example '[]' or
'[\\{"name":"ben"},\\{"name":"jane"}]'
* Formatted as NDJSON which would be '' or
'\{"name":"ben"}\n\{"name":"jane"}\n' where every line is valid JSON (unless
zero length)
was:
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 '[]', so the whole document is valid JSON, for example '[]' or
'[\{"name":"ben"},\{"name":"jane"}]'
* Formatted as NDJSON which would be '' or
'\{"name":"ben"}\n\{"name":"jane"}\n' where every line is valid JSON (unless
zero length)
> 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 '[]', so the whole document is valid JSON, for example '[]'
> or '[\\{"name":"ben"},\\{"name":"jane"}]'
> * Formatted as NDJSON which would be '' or
> '\{"name":"ben"}\n\{"name":"jane"}\n' where every line is valid JSON (unless
> zero length)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)