[Bug 27171] New: Outputting JSON, serializing sequences

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 27171] New: Outputting JSON, serializing sequences

Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27171

            Bug ID: 27171
           Summary: Outputting JSON, serializing sequences
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Serialization 3.1
          Assignee: [hidden email]
          Reporter: [hidden email]
        QA Contact: [hidden email]

I know I should have replied earlier to Michael's requests on serializing JSON
(#26784), but I think that one issue is worth being discussed a bit more:

If sequences with zero items or more than one item are to be output on top
level, I would recommend not to output them as 'null' or as array:

* To me, serialization has always been a non-blocking operation. If we don't
know in advance if a query will yield more than one item, and if we treat
sequences as arrays, we would from now on need to cache the first item before
we know if it needs to be prefixed with a square bracket.

* In my perception, all other output methods handle sequences differently.
Think of the XML output method: multiple nodes will simply be appended to each
other, and the result won't be wrapped by an additional root element.

* Similarly, if a query does not yield any result, I would expect it not to
return any output at all, as is the case with the other output methods.

If sequences occur on a deeper level, an error may be more appropriate. This
way, parsing and serializing JSON will be more bidirectional. See the following
query as example:

  map { 'A': ('B','C') }

If the value of the map object would now be serialized as array, and if it was
parsed via fn:parse-json, we would get a different result.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 27171] Outputting JSON, serializing sequences

Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27171

--- Comment #1 from Christian Gruen <[hidden email]> ---
A little addition: if the serialization of sequences is changed, the
item-separator parameter could be defined the same way as for the other output
methods.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 27171] Outputting JSON, serializing sequences

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27171

Jonathan Robie <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--- Comment #2 from Jonathan Robie <[hidden email]> ---
(In reply to Christian Gruen from comment #0)
> I know I should have replied earlier to Michael's requests on serializing
> JSON (#26784), but I think that one issue is worth being discussed a bit
> more:
>
> If sequences with zero items or more than one item are to be output on top
> level, I would recommend not to output them as 'null' or as array:

We have only one way to specify a JSON null, and that's an empty sequence. So I
think serializing as 'null' is appropriate here.

I agree that we should not serialize a sequence of length > 1 as an array. The
WG agreed to that yesterday.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 27171] Outputting JSON, serializing sequences

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27171

Christian Gruen <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Christian Gruen <[hidden email]> ---
> We have only one way to specify a JSON null, and that's an empty sequence.
> So I think serializing as 'null' is appropriate here.

After some thoughts, I also came to the conclusion that serializing an empty
sequence as 'null' also makes sense on top level (otherwise, serialization and
parsing would not be bidirectional anymore).

> I agree that we should not serialize a sequence of length > 1 as an array. The WG agreed to that yesterday.

Thanks for pointing this out; I'm closing this issue.

--
You are receiving this mail because:
You are the QA Contact for the bug.

Loading...