fn:parse-json

This function takes as input a string in JSON format and parses it typically returning a map or array.

parse-json($value as xs:string?, $options as map(*)?:={}) ➔ item()?

Arguments

 

$value

xs:string?

The JSON input to be parsed

 

$options

map(*)?

:= {}

Parsing options

Result

item()?

Namespace

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

Links to W3C specifications

XPath 3.1 Functions and Operators

XPath 4.0 Functions and Operators

Saxon availability

Available in XPath 3.1, XSLT 3.0, XQuery 3.1, and later versions. Available in all Saxon editions. Available for all platforms.

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 is available in Saxon-HE from Saxon 10; but requires Saxon-PE or Saxon-EE in earlier versions.

When liberal=true(), the following extensions to the JSON grammar are accepted:

See also:

fn:json-doc()

fn:json-to-xml()

fn:serialize()