W3C home > Mailing lists > Public > xproc-dev@w3.org > October 2011

RE: Totally non-conformant JSON hack

From: David Lee <dlee@calldei.com>
Date: Mon, 10 Oct 2011 15:05:43 -0400
To: "'Norman Walsh'" <ndw@nwalsh.com>, "'XProc Dev'" <xproc-dev@w3.org>
Message-ID: <017001cc877f$9c98aeb0$d5ca0c10$@calldei.com>
Sometimes more is better.
Why not also toss in the one that MarkLogic uses internally for its JSON/XML
implementation.
( unless its patented :)

I was thinking along the same lines for my json2xml/xml2json commands ... 
make the format an option.

http://www.xmlsh.org/CommandXml2json
http://www.xmlsh.org/CommandJson2xml

This is actually (both our use cases) a good case where options can be good
... as long as they are *options* ...
(as opposed to baked).


----------------------------------------
David A. Lee
dlee@calldei.com
http://www.xmlsh.org


-----Original Message-----
From: xproc-dev-request@w3.org [mailto:xproc-dev-request@w3.org] On Behalf
Of Norman Walsh
Sent: Monday, October 10, 2011 2:50 PM
To: XProc Dev
Subject: Re: Totally non-conformant JSON hack

David Lee <dlee@calldei.com> writes:
> Thanks, I'm going to start moving to this as well in xmlsh and JXON 
>
> The fewer "standards" doing exactly the same thing the better.

After some more thought over lunch, I think I may just make it
user-configurable. I have five variations in mind and it's not clear
that one is uniformly superior to all the others:

1. My own hack w/o a namespace (deprecated)
2. My own hack in the XProc step namespace
3. JSONx
4. JXON
5. An element-name based syntax with some escaping:

<j:json xmlns:j="http://marklogic.com/json" type="object">
   <j:id type="string">118051310819094153327</j:id>
   <j:_ type="string">empty string</j:_>
   <j:_0031foo_0024bar type="string">1foo$bar</j:_0031foo_0024bar>
   <j:x_003ahtml type="string">x:html</j:x_003ahtml>
   <j:nullvalue type="null"/>
   <j:foo_0024bar type="string">foo$bar</j:foo_0024bar>
   <j:image type="object">
      <j:url
type="string">https://lh5.googleusercontent.com/-XnZDEoiF09Y/AAAAAAAAAAI/AAA
AAAAAYCI/7fow4a2UTMU/photo.jpg</j:url>
   </j:image>
   <j:boolean type="boolean">false</j:boolean>
   <j:displayName type="string">Chirag Shah</j:displayName>
   <j:url
type="string">https://plus.google.com/118051310819094153327</j:url>
   <j:kind type="string">plus#person</j:kind>
   <j:array type="array">
      <j:item type="number">1</j:item>
      <j:item type="number">2</j:item>
      <j:item type="number">3</j:item>
   </j:array>
</j:json>

This one happens to work really well in an environment where you've got
an index on element names :-)

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 413 624 6676
www.marklogic.com
Received on Monday, 10 October 2011 19:06:22 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 10 October 2011 19:06:23 GMT