Changes

Jump to navigation Jump to search
30 bytes removed ,  14:38, 16 April 2019
=Conventions=
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/json</nowiki></code> namespace, which is statically bound to the {{Code|json}} prefix.<br/>All errors are assigned to the <code><nowiki>http://basex.org/errors</nowiki></code> namespace, which is statically bound to the {{Code|bxerr}} prefix.
==Conversion Formats==
The resulting representation consumes less memory than XML-based formats, and values can be directly accessed without conversion. Thus, it is recommendable for very large inputs and for efficient ad-hoc processing.
 
Before {{Version|9.0}}, the format was called {{Code|map}} (it has been renamed because the resulting value may also be a string, number, boolean, or an empty sequence).
==Options==
|-
| width='120' | '''Signatures'''
|{{Func|json:parse|$input string as xs:string?|elementitem(json)?}}<br/>{{Func|json:parse|$input string as xs:string?, $options as map(xs:string, xs:string*)?|item()?}}
|-
| '''Summary'''
|Converts the JSON data specified by {{Code|$inputstring}} to an XQuery value. If the input can be successfully parsed, it can be serialized back to the original JSON representation. The {{Code|$options}} argument can be used to control the way the input is converted.
|-
| '''Errors'''
|{{Error|BXJS0001parse|#Errors}} the specified input cannot be parsed as JSON document.<br/>{{Error|options|#Errors}} the specified options are conflicting.
|}
|-
| width='120' | '''Signatures'''
|{{Func|json:serialize|$input as item()?|xs:string}}<br/>{{Func|json:serialize|$input as item()?, $options as map(xs:string, xs:string*)?|xs:string}}
|-
| '''Summary'''
|Serializes the specified {{Code|$input}} as JSON, and returns using the result as specified {{Code|xs:string$options}} instance. , and returns the result as string:* The input is expected to conform to the results that are created by [[#json:parse|json:parse()]]. * Non-conforming items will be serialized as specified for in the [[XQuery 3.1#JSON Serialization|json output method]] of the official specificationrecommendation.<br />Items Values can also be serialized as JSON if with the standard [[Serialization|Serialization Parameter]] feature of XQuery:* The parameter {{Code|method}} is needs to be set to {{Code|json}}.<br/>The , and* the options presented in this article need to be assigned to the {{Code|$optionsjson}} argument can be used to control the way the input is serializedparameter.
|-
| '''Errors'''
|{{Error|BXJS0002serialize|#Errors}} the specified node cannot be serialized as JSON document.
|}
|Description
|-
|{{Code|BXJS0001options}}|The specified options are conflicting.|-|{{Code|parse}}
|The specified input cannot be parsed as JSON document.
|-
|{{Code|BXJS0002serialize}}
|The specified node cannot be serialized as JSON document.
|}
=Changelog=
 
; Version 9.1
* Updated: [[#json:parse|json:parse]] can be called with empty sequence.
;Version 9.0
* Updated: <code>map</code> format renamed to <code>xquery</code>.
* Updated: error codes updated; errors now use the module namespace
;Version 8.4
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu