Java access to JSON-to-XML transformation

Monday, 28 September 2015 · 2 messages · last reply 29 Sep 2015
HR
Hans-Juergen Rennau28 Sep 2015 14:23 #
Dear BaseX team, I have a question concerning the availability of the JSON-to-XML transformation. Before asking, this remark: I am very glad and grateful that BaseX offers this functionality (json:parse), as it exposes JSON to XPath, which enables important evaluations that otherwise would not even be attempted. And now my question. Is it possible - does it appear reasonable - to access the functionality within a Java application by calling the BaseX code (org.basex.build.json.JsonParser, I suppose)) immediately, without launching XQuery? I expect that one would be treading dangerous ground, relying on internal APIs which may change any time, not being meant for external use. If this is so, a brief confirmation would suffice to make me drop the idea. Thank you, and kind regards -Hans-Jürgen PS: Background of my question - I evaluate alternative possibilities how to validate JSON within Java applications. One (and probably the best) option is validating against JSON schema (json-schema.org), an alternative would be a to-XML transformation followed by XSD validation. A first experiment lettig BaseX via XQJ execute the epic query "json:parse(.)" revealed a performance which would not be sufficient to be competitive. So I wondered if removing the overhead of launching BaseX might be an approach to consider.
CG
Christian Grün29 Sep 2015 14:37 #
Hi Hans-Jürgen, Sure, that's possible. This is one of the entry points [1]. As you already indicated, it's not based on any well-defined API, so it is subject to change. Have you already done some testing what's the current bottleneck in terms of performance (e.g. by using the Java flag -Xhrunprof)? Maybe you can already save time by creating instances of the QueryProcessor class (see e.g. [2]). Cheers, Christian [1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/io/parse/json/JsonConverter.java#L71 [2] https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/RunQueries.java
Quoted text · Hans-Juergen Rennau · 29 lines
On Mon, Sep 28, 2015 at 2:23 PM, Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > Dear BaseX team, > > I have a question concerning the availability of the JSON-to-XML > transformation. Before asking, this remark: I am very glad and grateful that > BaseX offers this functionality (json:parse), as it exposes JSON to XPath, > which enables important evaluations that otherwise would not even be > attempted. And now my question. > > Is it possible - does it appear reasonable - to access the functionality > within a Java application by calling the BaseX code > (org.basex.build.json.JsonParser, I suppose)) immediately, without launching > XQuery? > > I expect that one would be treading dangerous ground, relying on internal > APIs which may change any time, not being meant for external use. If this is > so, a brief confirmation would suffice to make me drop the idea. > > Thank you, and kind regards - > Hans-Jürgen > > PS: Background of my question - I evaluate alternative possibilities how to > validate JSON within Java applications. One (and probably the best) option > is validating against JSON schema (json-schema.org), an alternative would be > a to-XML transformation followed by XSD validation. A first experiment > lettig BaseX via XQJ execute the epic query "json:parse(.)" revealed a > performance which would not be sufficient to be competitive. So I wondered > if removing the overhead of launching BaseX might be an approach to > consider.

⚡Generated with XQuery