fn:json-doc

Reads an external resource containing JSON, and returns the result of parsing the resource as JSON.

json-doc($href as xs:string?) ➔ item()?

Arguments

 

$href

xs:string?

The URI of the JSON file to be read

Result

item()?

json-doc($href as xs:string?, $options as map(*)) ➔ item()?

Arguments

 

$href

xs:string?

The URI of the JSON file to be read

 

$options

map(*)

Parsing options

Result

item()?

Namespace

http://www.w3.org/2005/xpath-functions

Links to W3C specifications

XPath 3.1 Functions and Operators

Saxon availability

Available in XPath 3.1, XSLT 3.0, and XQuery 3.1. Available in all Saxon editions. Implemented since Saxon 9.7.

Notes on the Saxon implementation

Available since Saxon 9.7. The parsing options recognized are 'liberal':true()|false(), 'duplicates':'reject'|'use-first'|'retain', 'escape':true()|false(), 'fallback':(function). For full details see the specification. Use of the fallback option requires Saxon-PE or Saxon-EE.

For the effect of the option liberal=true(), see parse-json().

The Saxon implementation also offers an additional option: 'number-parser' : xs:decimal#1 causes number values in the source JSON to be delivered as xs:decimal values rather than xs:double. This is useful where the values require higher precision than xs:double retains. It is also possible to return the string value as written using the option 'number-parser' : xs:string#1. In general, the value of the option is any function that takes as input the string value as written, and that delivers an atomic value containing the desired representation of the number.

See also:

fn:parse-json()

fn:json-to-xml()