Re: Wish-list
Brad Cox <[email protected]> Thu, 10 May 2012 20:05:56 -0400
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <CAH2etF65uLSzoVuO1Atjd91uM0PWi19kJ3AfEo6bYN_vqQUKWg@mail.gmail.com> |
Maybe you're seeing something I'm missing, but my reason for proposing this is to support JSON syntax (subsetted, minus namespaces and attributes) within the SAME (JDOM) data model. I see them as providing different syntax for the *same* semantics, in exactly the sense that the Java code my compilers generate for XACML are just another syntax with exactly the same semantics as in the original XML/XACML source. The same would/should be true of a JSON XACML source document. On Thu, May 10, 2012 at 5:21 PM, Michael Kay <[email protected]> wrote: > But JSON and XML are not just two different syntaxes. They are > fundamentally different data models. It's not at all clear why someone > would want to use something as complex as the XML data model to hold > something as simple as JSON. > > Michael Kay > Saxonica > > > On 10/05/2012 19:22, Brad Cox wrote: > > The best reason for doing it in JDOM I know of is for the two external > syntaxes to share EXACTLY the same DOM tree with flawless conversion > between them (subject to the JDOM as XML subset notion). If that could be > arranged with a separate tool that would do too. > > FWIW: The JDOM parser I settled on is Jackson. There are a bunch of > others. > > On Thu, May 10, 2012 at 1:02 PM, Michael Kay <[email protected]> wrote: > >> There's been a lot of work on JSON-to-XML and XML-to-JSON >> transformations. There is no single answer that works well in all cases. >> There is a tension between being lossless and producing something that is >> usable. An XML-to-JSON transformation that can handle mixed content may >> produce indigestible output for simple data-oriented XML. >> >> I don't think there is any good architectural reason to regard XML-JSON >> transformation as being part of the same component in the architecture as >> an XML tree model. Just because it needs doing doesn't mean it needs doing >> in JDOM. To me it's best kept separate. >> >> Michael Kay >> Saxonica >> >> >> On 10/05/2012 16:43, Rolf Lear wrote: >> >>> So, searching the interweb, I see some discussion about JSON parsers... I >>> don't see a SAX specific one, but there appear to be a number of >>> StAX-like >>> ones.... and we have StAX support directly now... ;-) >>> >>> Loading JSON in to JDOM is probably a lot simpler than the opposite >>> though.... >>> >>> I don't see how anything but a simple XML document could be output as a >>> JSON 'output'.... the challenge would be how to deal with the 'unusual' >>> XML-like concepts, rather than the easy stuff? >>> >>> Like, if your XML has a namespace, then what? >>> >>> Rolf >>> >>> On Thu, 10 May 2012 08:38:03 -0700, Chris Pratt<[email protected]> >>> wrote: >>> >>>> Correct me if I'm wrong, but all that JDOM would need for that to work >>>> would be a JSON SAX parser and a JSON Outputter. Those could even be >>>> packaged in a companion jar file for those that want the JDOM JSON >>>> >>> support. >>> >>>> (*Chris*) >>>> >>>> On Thu, May 10, 2012 at 4:12 AM, Brad Cox<[email protected]> >>>> >>> wrote: >>> >>>> This is based on experience using both, not a deep analysis. More with >>>>> XML >>>>> than JSON to date. This work was in the context of building XACML >>>>> compilers >>>>> that use the W3C DOM tree as their expression tree. And inspired by >>>>> recent >>>>> W3C mailing list discussions on standardizing a JSON syntax for XACML. >>>>> >>>>> They seem to be viewing JSON as I do, as a useful subset of XML, with >>>>> lack of namespaces and attributes the main differences I can think of >>>>> >>>> at >>> >>>> the moment. Lack of attributes not a problem for XACML; it hardly uses >>>>> them, just element values. >>>>> >>>>> The notion is to add a JSON parser in front that builds the same XML >>>>> (J)DOM tree you build now, plus a output path that converts the tree to >>>>> JSON on demand. The proposed extension is appealing because it would >>>>> allow >>>>> the same XACML compiler to accept standard XACML and/or standard JSON, >>>>> and >>>>> to trivially convert between the representations. >>>>> >>>>> On Wed, May 9, 2012 at 10:24 PM, Rolf Lear<[email protected]> wrote: >>>>> >>>>> I would *love* to hear how you expect JDOM (XML-based) and JSON to >>>>>> >>>>> 'hang >>> >>>> out' in the same place .... ;-) >>>>>> >>>>> -- >>>>> Cell: 703-594-1883 >>>>> Blog: http://bradjcox.blogspot.com >>>>> Web: http://virtualschool.edu >>>>> Manassas VA 20111 >>>>> >>>>> >>>>> _______________________________________________ >>>>> To control your jdom-interest membership: >>>>> http://www.jdom.org/mailman/options/jdom-interest/[email protected] >>>>> >>>>> _______________________________________________ >>> To control your jdom-interest membership: >>> http://www.jdom.org/mailman/options/jdom-interest/[email protected] >>> >>> _______________________________________________ >> To control your jdom-interest membership: >> http://www.jdom.org/mailman/options/jdom-interest/[email protected] >> > > > > -- > Cell: 703-594-1883 > Blog: http://bradjcox.blogspot.com > Web: http://virtualschool.edu > Manassas VA 20111 > > -- Cell: 703-594-1883 Blog: http://bradjcox.blogspot.com Web: http://virtualschool.edu Manassas VA 20111 _______________________________________________ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/[email protected]