<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>27171</bug_id>
          
          <creation_ts>2014-10-25 14:52:54 +0000</creation_ts>
          <short_desc>Outputting JSON, serializing sequences</short_desc>
          <delta_ts>2014-10-28 19:02:58 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Serialization 3.1</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://www.w3.org/Bugs/Public/show_bug.cgi?id=27107</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Christian Gruen">christian.gruen</reporter>
          <assigned_to name="C. M. Sperberg-McQueen">cmsmcq</assigned_to>
          <cc>jonathan.robie</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>113757</commentid>
    <comment_count>0</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2014-10-25 14:52:54 +0000</bug_when>
    <thetext>I know I should have replied earlier to Michael&apos;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 &apos;null&apos; or as array:

* To me, serialization has always been a non-blocking operation. If we don&apos;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&apos;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 { &apos;A&apos;: (&apos;B&apos;,&apos;C&apos;) }

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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113758</commentid>
    <comment_count>1</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2014-10-25 14:59:33 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114169</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2014-10-28 18:56:26 +0000</bug_when>
    <thetext>(In reply to Christian Gruen from comment #0)
&gt; I know I should have replied earlier to Michael&apos;s requests on serializing
&gt; JSON (#26784), but I think that one issue is worth being discussed a bit
&gt; more:
&gt; 
&gt; If sequences with zero items or more than one item are to be output on top
&gt; level, I would recommend not to output them as &apos;null&apos; or as array:

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

I agree that we should not serialize a sequence of length &gt; 1 as an array. The WG agreed to that yesterday.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114172</commentid>
    <comment_count>3</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2014-10-28 19:02:58 +0000</bug_when>
    <thetext>&gt; We have only one way to specify a JSON null, and that&apos;s an empty sequence.
&gt; So I think serializing as &apos;null&apos; is appropriate here.

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

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

Thanks for pointing this out; I&apos;m closing this issue.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>