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") return { "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.