[oslc-core] [oslc-cm] Problem with OSLC v1 style JSON representations
Dave
snoopdave at gmail.com
Thu Mar 4 09:03:17 EST 2010
Thanks Steve, Patrick and Andre. That addresses both of my concerns. I
will make sure the core spec matches the CM JSON representation.
- Dave
On Thu, Mar 4, 2010 at 8:54 AM, Andre Weinand <weinand at acm.org> wrote:
> Hi Dave,
>
> The following page shows how multi-valued attributes translate into JSON arrays:
> http://open-services.net/bin/view/Main/CmJsonFormatV1
>
> The use of JSON arrays results in a nice isomorphism to the collection construct we use for multi-valued attributes in the XML format.
>
> Regards,
> --andre
>
>
> On 04.03.2010, at 12:00, Patrick Streule wrote:
>
>> Hi Dave,
>>
>>> nicejson = "({\"foo\" \: \"bar\"})";
>>> niceobject = eval(nicejson);
>>> document.write("<p>niceobject.foo=" + niceobject.foo + "</p>");
>>
>> I agree that this nice, but allowing this in general would impose JS
>> language restrictions on property names. Not only the prefix notation is
>> problematic, also fully qualified identifiers like
>> 'com.example.properties.foo' would not work, and there may also be
>> conflicts with reserved words in JS.
>>
>>> // colons in JSON field names does not work (prefixed property
>> isundefined)
>>> annoyingjson = "({\"prefix:foo\" \: \"bar\"})";
>>> annoyingobject = eval(annoyingjson);
>>> document.write("<p>annoyingobject.prefix:foo=" + annoyingobject.foo
>>> + "</p>");
>>
>> You would write
>> document.write("<p>annoyingobject.prefix:foo=" + annoyingobject
>> ["prefix:foo"] + "</p>");
>>
>> This is only slightly longer than the dot notation.
>>
>>> // two properties with same name does not work (eval will fail)
>>> annoyingjson2 = "({\"foo\" \: \"bar\", \"foo\" \: \"baz\"})";
>>> annoyingobject2 = eval(annoyingjson2);
>>> document.write("<p>annoyingobject1.foo=" + annoyingobject1.foo +
>> "</p>");
>>
>> IMO, we should leverage JSON's support for arrays here, and not try to
>> translate an XML or RDF representation too literally to JSON. So the
>> example would be:
>>
>> annoyingjson2 = "({\"foo\" : [\"bar\", \"baz\"]})";
>> annoyingobject2 = eval(annoyingjson2);
>> document.write("<p>annoyingobject1.foo=" + annoyingobject1.foo +
>> "</p>");
>> for (var i= 0; i < annoyingobject1.foo.length; i++) {
>> document.write(annoyingobject1.foo[i]);
>> }
>>
>> Regards,
>> Patrick
>>
>>
>> _______________________________________________
>> Oslc-Cm mailing list
>> Oslc-Cm at open-services.net
>> http://open-services.net/mailman/listinfo/oslc-cm_open-services.net
>
>
More information about the Oslc-Core
mailing list