Re: Is there an equivalent to DocumentBuilder for JSON ?

Martin Honnen <[email protected]> Thu, 24 Jun 2021 23:05:51 +0200
Newsgroups gmane.text.xml.saxon.help
Organization Liberty Development
Message-ID <[email protected]>
On 24.06.2021 22:56, Martin Honnen wrote:

>> You can plug into the XdmFunctions for parse-json, however. You will get
>> a map or an array or a string, boolean or number from JSON parsing, not
>> an XdmNode.
>
> Like this:
>
>          Processor processor = new Processor(true);
>
>          XdmFunctionItem parseJsonFn =
> XdmFunctionItem.getSystemFunction(processor, new
> QName("http://www.w3.org/2005/xpath-functions","parse-json"), 1);
>
>          XdmValue input = parseJsonFn.call(processor, new
> XdmAtomicValue("[1, 2, 3]"));

Or for json-doc:

	XdmFunctionItem jsonDocFn =
XdmFunctionItem.getSystemFunction(processor, new
QName("http://www.w3.org/2005/xpath-functions", "json-doc"), 1);

         XdmValue input2 = jsonDocFn.call(processor, new
XdmAtomicValue("sample.json"));


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help