Saxon.Api

 

 

Saxon.Api

Class JsonBuilder


public class JsonBuilder

A JsonBuilder allows XDM values (typically maps and arrays) to be constructed by parsing JSON input

Property Summary

 bool Liberal

Specify whether parsing is to be strict or liberal. The default is strict, in which case input must conform strictly to the JSON specification. If the Liberal option is set, certain departures from JSON syntax are permitted (and ignored), for example an extra comma is allowed after the entries in an array or object.

 

Method Summary

 XdmValue parseJson (TextReader jsonReader)

Parse a JSON document supplied using a TextReader

 XdmValue parseJson (string json)

Parse a JSON document supplied as a string

 

Property Detail

Liberal

public bool Liberal {get; set; }

Specify whether parsing is to be strict or liberal. The default is strict, in which case input must conform strictly to the JSON specification. If the Liberal option is set, certain departures from JSON syntax are permitted (and ignored), for example an extra comma is allowed after the entries in an array or object.

Method Detail

parseJson

public XdmValue parseJson(TextReader jsonReader)
throws
SaxonApiException

Parse a JSON document supplied using a TextReader

Parameters:

jsonReader - Delivers the JSON input text

Returns:

Typically an XdmMap or XdmArray containing the parsed representation of the JSON input text. If the JSON comprises a single token, the returned value may be an XdmAtomicValue containing a string, number, or boolean; or an empty sequence representing JSON null.

Throws:

SaxonApiException - If the JSON input is invalid

parseJson

public XdmValue parseJson(string json)
throws
SaxonApiException

Parse a JSON document supplied as a string

Parameters:

json - Contains the JSON input text

Returns:

Typically an XdmMap or XdmArray containing the parsed representation of the JSON input text. If the JSON comprises a single token, the returned value may be an XdmAtomicValue containing a string, number, or boolean; or an empty sequence representing JSON null.

Throws:

SaxonApiException - If the JSON input is invalid