[oslc-core] [oslc-cm] Problem with OSLC v1 style JSON representations

Andre Weinand weinand at ACM.ORG
Thu Mar 4 09:01:00 EST 2010


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