Skip to content
Main menu
  • Main page
  • Discover
  • Unexpected connections
  • Topics
  • Random article
  • Search
Your library
  • Saved articles
  • Recent discoveries
  • Rabbit-hole trails
Topic areas
  • Computer Science
  • Mathematics
  • Physics
  • Engineering
  • Biology
  • Economics
  • Curiosities
WikiholeDeeper into Wikipedia
EnglishEN
  • Saved
  • History

  • Article text and media come live from Wikipedia via the official MediaWiki API and are available under the Creative Commons Attribution-ShareAlike 4.0 License; additional terms may apply. Each article links to its source and revision.
  • WikiHole is an independent project and is not affiliated with the Wikimedia Foundation.
  • How ranking works
  • All topics
  • Reading history
  • Random article
  • MediaWiki API

JSONiq

  • Article
  • Rabbit hole
  • Read
  • View history
Tools
Actions
  • Read
  • View history
General
  • Recent changes
  • Related articles
  • Random discovery
This article
Reading time
3 min
Topic
Computer Science
Quality
Start-class
Views
50 in 14 days
Last edited
10 Jun 2026
Print/export
  • Printable version
In other projects
  • Wikidata item
From Wikipedia, the free encyclopedia
Rabbit hole:
  1. JSONiq
JSONiq
Paradigmdeclarative, functional, modular
Typing disciplinedynamic, strong
OSCross-platform
Filename extensions.jq, .jqy
Websitewww.jsoniq.org

JSONiq is a query and functional programming language that is designed to declaratively query and transform collections of hierarchical and heterogeneous data in format of JSON, XML, as well as unstructured, textual data.

JSONiq is an open specification published under the Creative Commons Attribution-ShareAlike 3.0 license. It is based on the language, with which it shares the same core expressions and operations on . comes in two syntactical flavors, which both support JSON and XML natively.

XQuery
atomic types
JSONiq
  1. The JSONiq syntax (a superset of JSON) extended with XML support through a compatible subset of XQuery.
  2. The XQuery syntax (native XML support) extended with JSON support through a compatible subset (the JSONiq extension to XQuery) of the above JSONiq syntax.

Loading the rest of the article…

Recent changes

Rabbit hole

Where JSONiq leads. Every connection below has a source: a link in this article, a shared Wikipedia category, or CirrusSearch text similarity. Articles already on your trail are left out.

Contents
  • (Top)
  • Features
  • Examples
  • Applications
  • Comparison of the two syntactic flavors
  • Further reading
  • Implementations
  • See also
  • Recent changes
  • Rabbit hole
Contents
Contents9 sections
  • (Top)
  • Features
  • Data model
  • Examples
  • Applications
  • Comparison of the two syntactic flavors
  • JSONiq syntax
  • XQuery syntax with JSONiq extension
  • Further reading
  • Implementations
  • See also
  • Recent changes
  • Rabbit hole

Features

JSONiq primarily provides means to extract and transform data from JSON documents or any data source that can be viewed as JSON (e.g. relational databases or web services).

The major expression for performing such operations is the SQL-like “FLWOR expression” that comes from XQuery. A FLWOR expression is constructed from the five clauses after which it is named: FOR, LET, WHERE, ORDER BY, RETURN. However, it also supports clauses for doing grouping and windowing.

The language also provides syntax for constructing new JSON documents where either the field names and values are known in advance or can be computed dynamically. The JSONiq language (not the extension to XQuery) is a superset of JSON. That is, each JSON document is a valid JSONiq program.

Additionally, the language also supports a navigational syntax for extracting field names and values out of JSON objects as well as values out of JSON arrays. Navigation is resilient in the absence of values, or if values are heterogeneous, in that it silently ignores unforeseen values without raising errors.

All constructs are defined as expressions within the language and can be arbitrarily nested.

JSONiq does not include features for updating JSON or XML documents, it does not have full text search capabilities, and has no statements. All of these features are under active development for a subsequent version of the language.

JSONiq is a programming language that can express arbitrary JSON to JSON or XML to XML transformations. It also allows for transformations between JSON and XML. All such transformations have the following features:

  1. Logical/physical data independence
  2. Declarative
  3. High level
  4. Side-effect free
  5. Strongly typed

Data model

The language is based on the JSONiq Data Model (JDM) which is an extension of the XQuery and XPath Data Model (XDM). The JDM uses a tree-structured model of the information content of a JSON or XML document. It contains JSON objects, JSON arrays, all kinds of XML nodes, as well as atomic values such as integers, strings, or boolean all being defined in XML Schema.

JDM forms the basis for a set-oriented language, in that instances of the data model are sequences (a singleton value is considered to be a sequence of length one). The items in a sequence can be JSON objects, JSON arrays, XML nodes, or atomic values.

Examples

The sample JSONiq code below computes the area code and the number of all people older than 20 from a collection of JSON person objects (see the JSON article for an example object).

 for $p in collection("persons")
 where $p.age gt 20
 let $home := $p.phoneNumber[][$$.type eq "home"].number
 group by $area := substring-before($home, " ")
 return 
   {
     "area code" : $area,
     "count" : count($p)
   }

All JSONiq constructs are expressions and can also be contained in the body of a function.

 declare function local:adults()
 {
   for $p in collection("persons")
   where $p.age gt 20
   return $p
 };

The next query transforms parts of each person object into an XML element using the XQuery syntax (JSONiq extension to XQuery).

 for $p in collection("persons")
 return 
   <person>
     <firstName>{$p("firstName")}</firstName>
     <lastName>{$p("lastName")}</lastName>
     <age>{$p("age")}</age>
   </person>

Applications

Below are a few examples of how and where JSONiq can be used:

  1. Extracting information out of a database to use in a web service.
  2. Generating summary reports on data stored in a JSON document store.
  3. Selecting and transforming JSON data to XHTML to be published on the Web.
  4. Correlating data from various sources and formats (e.g. JSON document store, XML database, relational database, and web service) and offer it in a web service.
  5. Transforming collections of JSON objects into a different schema.

Comparison of the two syntactic flavors

There are two syntaxes of JSONiq, which users can use on whether they are focusing on JSON or XML. Both syntaxes use the same data model and are very similar up to a few exceptions.

JSONiq syntax

The pure JSONiq syntax is a superset of JSON. It is not strictly speaking a superset of XQuery even though all its expressions and semantics are available. The following aspects of the JSONiq syntax are not XQuery conformant:

  1. No names containing dots.
  2. No . for the context item ($$ has to be used instead).
  3. No single-quoted literals.
  4. JSON, backslash-based escaping in string literals.
  5. No axis step allowed at the beginning of a relative path expression.

XQuery syntax with JSONiq extension

The JSONiq extension to XQuery is a superset of XQuery but not a superset of JSON. It is fully conformant and backwards compatible with XQuery 3.0 candidate recommendation. The following aspects of JSONiq are not supported in the XQuery syntax.

  1. No dot-based object lookup ($object(“key”) instead).
  2. No $$ for the context item.
  3. XML, ampersand-based escaping of string literals.
  4. Object keys must be quoted
  5. No true/false/null literals
  6. Built-in atomic types must be prefixed with xs:.
  7. Non-atomic types must be followed by parentheses.
  8. The empty-sequence() must be written as such.
  9. No array lookup and no [] array unboxing.

Further reading

  • JSONiq - The SQL of NoSQL. Ghislain Fourny. CreateSpace Independent Publishing Platform. ISBN 1489530371.

Implementations

  • Zorba: JSONiq and JSONiq Extension to XQuery
  • IBM WebSphere: JSONiq extension to XQuery
  • BeniBela Internet Tools: JSONiq extension to XQuery

See also

  • JMAP
Categories:
  • JSON
  • Functional languages

877 words · 0 references · revision 1358683029 · CC BY-SA 4.0

General
  • Recent changes
  • Related articles
  • Random discovery
This article
Reading time
3 min
Topic
Computer Science
Quality
Start-class
Views
50 in 14 days
Last edited
10 Jun 2026

Key concepts

  • JSON2
  • Query language1
  • Functional programming1
  • XML1
  • Open specification1
  • Creative Commons license1
  • ShareAlike1
  • XQuery1
  • Atomic type1
  • Subset1

The articles this one links to most, weighted towards the introduction.

Print/export
  • Printable version
In other projects
  • Wikidata item
Created
11 Aug 2013
History
21 edits
17 contributors
No edits in the last 30 days
Last edited
10 Jun 2026

21 revisions in total · 17 contributors

  1. 10 Jun 2026, 07:27 UTCأحمدSee also: JMAP+27diff
  2. 12 Apr 2025, 10:58 UTCHka-34 JyliNo edit summary+32diff
  3. 9 Dec 2023, 04:19 UTCApokrifm§ top+16diff
  4. 5 Aug 2021, 10:37 UTCQwerfjklmImporting Wikidata short description: "Query and functional programming language" (Shortdesc helper)+64diff
  5. 2 Mar 2021, 02:26 UTCCedar101§ Examples lang="xquery"+2diff
  6. 27 Jan 2020, 10:53 UTCFrap§ Data Model MOS:HEAD0diff
  7. 18 Apr 2019, 12:35 UTCAnonymous contributor§ Implementations dead link−80diff
  8. 6 Dec 2017, 20:57 UTCAnonymous contributorRemoving "Future work" section, which was outdated and lacked references.−549diff

View full revision history

Created
11 Aug 2013
History
21 edits
17 contributors
No edits in the last 30 days
Last edited
10 Jun 2026

Related articles are unavailable right now.

Wikipedia is rate limiting us right now. Try again in a minute.