Chapter 3. JSONiq Data Model
JSONiq is based on the XQuery Data Model, adding support for JSON nulls, objects and arrays. []
JSON's simple values can have any of the following datatypes, which are supported as primitives in JSONiq.
string
number
boolean (true, false)
null
JSONiq represents a JSON string (a sequence of Unicode characters) as an xs:string. However, JSON supports strings (after resolving escaped characters) with characters of arbitrary unicode codepoints, whereas XML 1.0 and XML 1.1 only support a subset of these. It is implementation-defined if unicode characters outside of XML 1.0 or XML 1.1 are supported. Implementations which support XML 1.1 (which only excludes the null character) are encouraged to add support for the null character to provide full-fledged JSON support.
JSONiq represents the JSON simple values 'true' and 'false' as xs:boolean
values.
JSONiq adds one new data type: js:null
, derived from xs:anyAtomicType
. js:null
has a singleton value space containing the value null []. The lexical representation of an instance of js:null
is the string "null
".
JSON defines number as follows:
A number can be represented as integer, real, or floating point. JSON does not support octal or hex because it is minimal. It does not have values for NaN or Infinity because it does not want to be tied to any particular internal representation.
JSONiq uses XQuery's lexical representation of numbers to distinguish integer, real, and floating point numbers []:
NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral
If a numeric literal has no "." character and no e or E character, it has the atomic type xs:integer
; if it has a "." character but no e or E character it has type xs:decimal
; if it has an e or E character it has type xs:double
.
Number literals are mapped to atomic values according to the XML Schema specification.