Re: Totally non-conformant JSON hack

David Lee <dlee@calldei.com> writes:

> I must have missed this "conformant" XML-JSON mapping.

It's conformant for p:unescape-markup to convert JSON to XML because the spec says

  An implementation may use a different parser to produce XML content
  depending on the specified content-type. For example, an
  implementation might provide an HTML to XHTML parser (e.g. [HTML
  Tidy] or [TagSoup]) for the content type 'text/html'.

For the content type "application/json", I use a parser that produces XML like this:

<c:json xmlns:c="http://www.w3.org/ns/xproc-step" type="object">
   <c:pair name="id" type="string">1180513108190941...</c:pair>
   <c:pair name="nullvalue" type="null"/>
   <c:pair name="image" type="object">
      <c:pair name="url" type="string">https://...</c:pair>
   </c:pair>
   <c:pair name="boolean" type="boolean">false</c:pair>
   <c:pair name="displayName" type="string">John Doe</c:pair>
   <c:pair name="kind" type="string">plus#person</c:pair>
   <c:pair name="url" type="string">https://...</c:pair>
   <c:pair name="array" type="array">
      <c:item type="number">1</c:item>
      <c:item type="number">2</c:item>
      <c:item type="number">3</c:item>
   </c:pair>
</c:json>

There's nothing particularly elegant or nice about that markup, but
the first reasonable Java library I found produced it. And it does
have the benefits of being regular and handling arbitrary names.

I'm open to suggestions for better vocabularies, I suppose.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 413 624 6676
www.marklogic.com

Received on Monday, 10 October 2011 13:19:56 UTC