Corrections on JSON support

All,

I have looked a bit more closely at the JSON conversion. [1] I think
the following are just obvious corrections, but Steven should be able
to confirm:

1. JSON syntax error in example 16

This is an easy one.

Current text:

    {g: [["a", "b", "c"], ["d", "e"]]

should be:

     {"g": [["a", "b", "c"], ["d", "e"]]}

In JSON, property names must be quoted, and there is a missing brace.

2. Probable error in example 10

Current text:

    <json object="true"><p/></json>

should probably be:

    <json object="true"><p object="true"/></json>

The source JSON is:

    {"p": {}}

The spec text says:

    "An object is transformed by adding an attribute object="true" to
its containing element"

I think it should apply to the empty object as well, unless there is a
really good reason not to do it.

And example 17, with an empty top-level object does have the attribute:

    <json object="true"/>

3. Missing explanatory text

The spec text says:

    "If a value is an (anonymous) array (either being the top-level
value, or itself an element of an array), then each element of the
transformed array is given the name "_" and an attribute name="" is
added to the element."

But this doesn't mention to also add `array="true"` to the element.
The examples do have `array="true"`. I suggest clarifying that.

4. Missing `object="true"` in example 6

Current XML:

    <json object="true">
       <father><given type="string">Mark</given><family
type="string">Smith</family></father>
       <mother><given type="string">Mary</given><family
type="string">Smith</family></mother>
    </json>

As above, the spec text says:

    "An object is transformed by adding an attribute object="true" to
its containing element"

I suggest that this should be instead:

    <json object="true">
       <father object="true"><given type="string">Mark</given><family
type="string">Smith</family></father>
       <mother object="true"><given type="string">Mary</given><family
type="string">Smith</family></mother>
    </json>

Comments welcome,

-Erik

[1] https://www.w3.org/community/xformsusers/wiki/XForms_2.0#External_JSON_values

Received on Wednesday, 18 November 2015 20:17:35 UTC