JSONURL
Type code | TEXT |
---|---|
Type of format | Data interchange |
Extended from | JSON |
Open format? | Yes |
Website | jsonurl |
JSON→URL is a language-independent data interchange format for the JSON data model[1] suitable for use within a URL/URI query string. It is defined by an open specification [2], though not through a standards body.
Data types and syntax
JSON→URL implements the JSON data model[1], with support for the following data types[2]:
- Number: a signed decimal number that may contain a fractional part and may use exponential E notation, but cannot include non-numbers such as NaN. The format makes no distinction between integer and floating-point.
- Boolean: either of the values
true
orfalse
- null: an empty value, using the word
null
- String: a sequence of zero or more Unicode characters. Strings may be delimited with single-quotation marks if the unquoted value would otherwise be interpreted as a boolean, null, or number. Otherwise, they need not be quoted. Characters which are not valid in a URL must be percent encoded. Space is encoded as
+
or%20
. - Array: an ordered list of one or more values, each of which may be of any type. Arrays use parentheses notation with comma-separated elements.
- Object: a collection of one or more name–value pairs where the names (also called keys) are strings. Objects are intended to represent associative arrays,[3] where each key is unique within an object. Objects are delimited with parentheses and use commas to separate each pair, while within each pair the colon character separates the key or name from its value.
- Empty: the empty composite value
Example
The following example shows a possible JSON→URL representation describing a person.
(firstName:John,lastName:Smith,isAlive:true,age:27,address:(streetAddress:21+2nd+Street,city:New+York,state:NY,postalCode:10021-3100),phoneNumbers:((type:home,number:212+555-1234),(type:office,number:646+555-4567)),children:(),spouse:null)
Differences from JSON
JSON→URL implements the JSON data model[1], however, it does not differentiate between an empty object and an empty array. Instead, it defines an empty composite value as ()
.
Data portability
JSON→URL exchange in an open ecosystem must be encoded in UTF-8.[2] The encoding supports the full Unicode character set, including those characters outside the Basic Multilingual Plane (U+10000 to U+10FFFF). Unlike JSON, JSON→URL does not define a separate syntax for escaping characters within a string literal. Such characters are simply composed of one or more percent encoded octets.
Numbers in JSON→URL are agnostic with regard to their representation within programming languages. While this allows for numbers of arbitrary precision to be serialized, it may lead to portability issues. For example, since no differentiation is made between integer and floating-point values, some implementations may treat 42
, 42.0
, and 4.2E+1
as the same number, while others may not. The JSON→URL standard makes no requirements regarding implementation details such as overflow, underflow, loss of precision, rounding, or signed zeros.
Semantics
While JSON→URL provides a syntactic framework for data interchange, unambiguous data interchange also requires agreement between producer and consumer on the semantics of a specific use of the JSON→URL syntax. One example of where such an agreement is necessary is the serialization of data types local to a specific implementation (e.g. Java, JavaScript) that are not defined in the JSON→URL specification, such as Date.
References
- ↑ 1.0 1.1 1.2 "The JavaScript Object Notation (JSON) Data Interchange Format". IETF. December 2017. https://tools.ietf.org/html/rfc8259. Retrieved 16 February 2018.
- ↑ 2.0 2.1 2.2 "JSON→URL Specification". Ongoing. https://jsonurl.github.io/specification/. Retrieved 20 July 2020.
- ↑ "The JSON Data Interchange Format". ECMA International. October 2013. https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-404%201st%20edition%20October%202013.pdf. Retrieved 24 October 2019.
External links
Template:AFC submission/created Script error: No such module "AFC submission catcheck".
Original source: https://en.wikipedia.org/wiki/JSONURL.
Read more |