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

Dave snoopdave at gmail.com
Wed Mar 3 15:52:53 EST 2010


Thanks Steve. I think we need a JavaScript coder to chime in here.
Below is a simple HTML/JavaScript example that illustrates the two
problems I mentioned.

The escaping makes the example hard to follow, so here is the nice JSON:
   { "foo" : "bar" }

Here is annoyingjson1:
   { "prefix:foo" : "bar" }

And here is annoyingjson2:
   { "foo" : "bar",
     "foo" : baz" }

And finally, here is the HTML/JavaScript example:

   <html>
   <head>
   <script type="text/javascript">

   nicejson = "({\"foo\" \: \"bar\"})";
   niceobject = eval(nicejson);
   document.write("<p>niceobject.foo=" + niceobject.foo + "</p>");

   // colons in JSON field names does not work (prefixed property is undefined)
   annoyingjson = "({\"prefix:foo\" \: \"bar\"})";
   annoyingobject = eval(annoyingjson);
   document.write("<p>annoyingobject.prefix:foo=" + annoyingobject.foo
+ "</p>");

   // 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>");

   </script>
   </head>
   </html>

Hope that helps...

- Dave




More information about the Oslc-Cm mailing list