View Issue Details

IDProjectCategoryView StatusLast Update
000775010000-006: MappingsSpecpublic2023-01-03 16:45
Reporterjpfr Assigned ToRandy Armstrong  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionwon't fix 
Fixed in Version1.05.03 RC1 
Summary0007750: JSON null arrays (length -1) not defined
Description

In an automated roundtrip test of binary -> JSON -> binary we stumbled across the following.

An empty array has either a defined length of 0 or it can be a "null array" of length -1.
Some applications care about the distinction where the -1 array is undefined/unknown, which is different from a known empty array.

The current spec for the JSON mapping doesn't say how to make the distinction between the two types of empty array.
An easy way out would be to use "null" for the -1 array and "[]" for the 0 array.

By consequence, a variant with a "null" body would contain a -1 array of the given type.
As I read the spec, "null" would currently be forbidden for a variant body, so that is backwards compatible.

Then comes the next can of worms: String, ByteString and XmlElement can all have length -1 as well.
We could say that the JSON "null" indicates the null-string in the appropriate places.
But then the meaning of a variant {"Type":12, "Body":null} clashes with the above proposal.
The body could then either be a null-string or a null-array of strings.

However this is resolved, a complete bidirectional mapping between binary and JSON should be possible.

TagsNo tags attached.
Commit Version
Fix Due Date

Activities

jpfr

2022-02-25 17:21

reporter   ~0016111

While the original report outlines the issue, here's a solution proposal that is backwards compatible with the current spec:

In general:

  • null either represents the null value or the null array (length -1)
  • '[]' represents the empty array (length 0)
  • '{}' (JSON object with no content) also represents the null value

With that, all options are covered for the Variant:
{"Type":12, "Body":{}} --> the null value (string of length -1)
{"Type":12, "Body": ""} --> the empty string (length 0)
{"Type":12, "Body": null} --> A null array (length -1)
{"Type":12, "Body": []} --> the empty array

Randy Armstrong

2022-12-28 01:40

administrator   ~0018353

Last edited: 2022-12-28 01:41

The premise that the distinction between -1 and 0 length matters is wrong. See

5.1.9 Null, Empty and Zero-Length Arrays

A null array has no value. A zero-length or empty array is an array with 0 elements. Some DataEncodings will allow the distinction to be preserved on the wire, however, not all DevelopmentPlatforms will be able to preserve the distinction. For this reason, null, empty and zero length arrays are semantically the same for all DataEncodings.
...
Decoders shall be able to handle all variations supported by the DataEncoding, however, decoders are not required to preserve the distinction.
...

Jim Luth

2023-01-03 16:45

administrator   ~0018390

Agreed to no-fix in telecon.

Issue History

Date Modified Username Field Change
2022-02-20 23:24 jpfr New Issue
2022-02-25 17:21 jpfr Note Added: 0016111
2022-03-01 17:51 Jim Luth Assigned To => Randy Armstrong
2022-03-01 17:51 Jim Luth Status new => assigned
2022-12-28 01:40 Randy Armstrong Status assigned => resolved
2022-12-28 01:40 Randy Armstrong Resolution open => won't fix
2022-12-28 01:40 Randy Armstrong Note Added: 0018353
2022-12-28 01:41 Randy Armstrong Note Edited: 0018353
2022-12-28 06:43 Randy Armstrong Fixed in Version => 1.05.03 RC1
2023-01-03 16:45 Jim Luth Status resolved => closed
2023-01-03 16:45 Jim Luth Note Added: 0018390