JSONiq: The JSON Query Language

| by Jonathan Allen Follow 499 Followers on Oct 08, 2012. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

JSONiq is a new query language that builds upon XQuery. Like SQL or LINQ, it has syntactic support concepts such as let, for, where, group by, and select. Here is an example:

let $stats := db:find("stats")
for $access in $stats
where $access("response_time") > 5
group by $url := $access("url")
    "url": $url,
    "avg": avg($access("response_time")),
    "hits": count($access)

JSONiq supports than just JSON to JSON transformations. You can use it to generate or parse XML and even create queries that merge the two. In this example from the documentation, you can see JSONiq being used as a template language to generate HTML tables.

Like XQuery, JSONiq supports overlapping and non-overlapping windows. This feature is used for breaking data into evenly sized chunks or for statistical calculations such as “last 3” averages. You can learn more about tumbling and sliding windows in the XPath specification.

Another feature of JSONiq is the ability to update JSON data. In this example, you can see a status property being inserted into records that match the name "Deadbeat Jim".

JSONiq is available as part of the XQuery processor Zorba, which is distributed under Apache 2 License. JSONiq itself is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

MongoDB driver by William Candillon

A mongodb driver has already been implemented on top of JSONiq.
You can try it live at

Looks somewhat like XQuery by Faisal Waris

the syntax closely resembles XQuery - the language for querying xml documents

Theoretically, How does this differ from Ember.js query model? by Guy Ndjeng

Pretty cool!!
Technically I think it's a good initiative but in theory, how does this differ from Larger JS framework like Ember.js which provides a JSON query model that developers have adopted? The other question is how does this play with others?
Moreover, I am hearing that ECMAScript 5 will have an inherent mechanism for querying Javascript Objects which should address this problem..

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

3 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you