JSONiq | JSONiq Specification -
kandi X-RAY | JSONiq Summary
kandi X-RAY | JSONiq Summary
JSONiq Specification
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of JSONiq
JSONiq Key Features
JSONiq Examples and Code Snippets
Community Discussions
Trending Discussions on JSONiq
QUESTION
Using the JSONiq to JavaScript implementation of JSONiq, say I have an array
...ANSWER
Answered 2021-Feb-20 at 12:36In the core JSONiq syntax, an array is turned into a sequence (i.e., its members are extracted) with an empty pair or square brackets, like so:
QUESTION
I've explored couple of existing JSON query language such JMESPath, JsonPath and JSONiq. Unfortunately, none of them seem to be able to support my use case in a generic way.
Basically, I'm receiving different type of responses from different web services. I need to give the ability to the user to remap the response in a 2 dimensional array in other to leverage our visualization tool. Based on the new format, the user can decide how to display his data between existing widgets. Pretty much like a customisable dashboard entirely managed on the UI.
Anyway my input looks like:
...ANSWER
Answered 2020-May-21 at 20:55Finally, managed a way with JSONiq using Zorba implementation. Definitively the way to go if you need powerful JSON queries. Apparently this has been integrated in Apache Spark with Rumble
Anyway, here's my solution:
QUESTION
I have looked everywhere, and even the JSONiq documentation says "this is beyond the scope of this document." I have a JSON file (an array of JSON objects) I want to import into JSONiq (particularly Zorba, which by the way is a terrible name because it makes Internet searches for information futile) to use as a collection to query. Is there a tutorial, or spec, or anything anywhere that tells me how to do this?
...ANSWER
Answered 2018-Jun-13 at 07:06Zorba supports adding documents to a collection. The framework for doing so is documented here. Note, however, that Zorba is a memory store and will not persist anything beyond the scope of one query, so that this is of limited use without a persistence layer.
If the use case is simply to query a JSON file stored on your local drive, then it may be simpler to use EXPath's file module as well as parse-json, like so:
QUESTION
I've seen statements that JSONiq query language also supports processing XM, but the only example I found is in the JSONiq Wikipedia article. It looks like XML processing is only possible with the "JSONiq extension to XQuery" but this is not the same as JSONiq, isn't it? The JSONiq specification does not include XML syntax, so it should be forbidden?
...ANSWER
Answered 2019-Sep-24 at 14:06The core JSONiq language supports only JSON, in the same the core XQuery language supports only XML. However, there are many people who want to query both XML and JSON in the same program, for example to convert one to the other. This is why there are extensions (both ways). Rather than forbidden, I would say that they are optional (and actually encouraged).
If the data is a mix of JSON and XML, then you can use either the "JSONiq extension to XQuery" or the "XQuery extension to JSONiq." The differences are minor and revolve around convenience. Feature-wise, both are equivalent.
The exact differences are comprehensively documented here
A complete grammar with JSONiq, the XQuery extension and even updates and scripting is available here.
If there is a lot of JSON and a bit of XML, then "the "XQuery extension to JSONiq" is more adequate: you can query JSON with dots and escaping in strings is done with backslashes, and literals like null
, true
and false
are recognized, but any XPath name queries on XML Names must be prefixed by ./ (./foo
instead of just foo
), etc.
If there is a lot of XML and a bit of JSON, the "JSONiq extension to XQuery" is more adequate. It is the opposite: the exact, W3C-compliant XPath syntax is supported and string escaping with ampersands, but for example booleans and nulls must be written as true()
, false()
, null()
to not interfere with XPath.
The Zorba engine supports both of the variants, and you can switch using xquery version "3.0"
or jsoniq version "1.0"
in the header of the query, with no further configuration: if you use JSONiq, the XQuery extension is always available as well, and if you use XQuery, the JSONiq extension is always available.
If no header is present, then the extension .xq
or .jq
is used to infer the language used.
Whether or not a JSONiq processor supports the XQuery extension is a decision of the software provider. In general, we encourage implementors of a JSONiq engine to support the XQuery extension if they have the resources. Providers who want to keep a very lightweight engine will stick to core JSONiq.
The other way round, extending an existing XQuery engine with the JSONiq extension is very easy: when we did so in Zorba when we started supporting JSON, it only took us a few days because the JSON data model is so simple. There is a talk by Jonathan Robie sharing experience on this topic on Youtube.
QUESTION
Looking at the implementation of the JSONiq specification (www.jsoniq.org).
Most of them are standalone deployment. e.g. Zorba, VXQuery, etc and are designed to query JSON based databases or process large JSON documents.
I am surprised to find all implementations are trying to solve such problem without modularizing the JSONiq execution as library. It should have been much like Apache Lucene(library) to Apache Solr(Search Server+Rest API) and other indexing solution.
Is there a java library available (similar to Saxon for XQuery), which can be embeded into java apps and can execute the JSONiq specs defined as functions in .xq or .xquery files ? Or How can Saxon be extended to parse and execute the JSONiq specification ?
...ANSWER
Answered 2017-Jul-06 at 21:08JSONiq is an XQuery-like language for processing JSON. Most of its good ideas were incorporated into XQuery 3.1, but in a way that integrated the XML and JSON data models. I don't believe JSONiq offers any functionality that's not in XQuery 3.1, and it's not an open standard, so there would be little point in implementing it in Saxon.
QUESTION
The question is to write a JSONiq FLWOR expression that can display the name of the products which their price are at least 3.
I have tried the answers provided on How to run JSONiq from JSON with try.zorba.io but that's not the answers that i expect. Beside that, I also tried a lot of JSON FLWOR expression but still getting errors in try.zobia.io. This is my JSON file.
...ANSWER
Answered 2019-Mar-30 at 10:42visit
also is an array, so you need the parenthesis to get to the individual visits in the for
. This
QUESTION
I need to write a JSONiq expression that lists only the name of the products that cost at least 3. This is my JSON file which i had typed in the XQuery section:
...ANSWER
Answered 2019-Mar-15 at 12:26The following selection works for me at the site you linked to:
QUESTION
Is it possible to use Zorba (and xquery/jsoniq) to query documents stored in something other than a filesystem? I saw a slidedeck from 28msec and others that suggested they had done this, but I wasn't sure how. I didn't know if they used 3rd party code or something else.
I tried and liked Basex but it doesn't support JSONiq and I believe doesn't scale out.
...ANSWER
Answered 2019-Jan-03 at 10:46Zorba can query not only the local file system, but also any documents stored in a way accessible via a REST API.
First, Zorba provides a few built-in modules to connect to Couchbase, SQL databases, etc
http://www.zorba.io/documentation/latest/modules/connectors
Second, support for more stores can be implemented using the REST module:
http://www.zorba.io/documentation/latest/modules/zorba/io/http-client
For each new document store to be supported, it is common to create a new user-defined module that wraps the REST calls into a JSONiq module API that mimics that of a document store, in a way that maps naturally to the underlying REST API (e.g., connect, get, put, update, delete, ...). The parameters of this module's functions can be JSON objects or XML documents almost identical to those actually passed as content/body to the REST API (e.g., query by example).
With knowledge of the module syntax, this usually takes about 1000 lines of code and a few days to do, and if applicable can easily be shared with other users for example on GitHub as it is mostly a single module file. Some such modules may be available online.
It should also be said that Zorba supports the standardized EXPath HTTP client as well (similar to the other one, but with general parameters passed in XML format instead of JSON). This means that any modules designed to query XML-based document stores should even be interoperable with XQuery/JSONiq engines besides Zorba.
Document stores that do not support REST can also be supported, but this requires C++ coding and is significantly more involved.
Since you mention scaling up, I should also mention Sparksoniq, which scales up to query JSON data (tested up to a few billion objects) stored on HDFS.
I hope this helps you further.
QUESTION
New to JSONIQ,and using zorba what I want to do so far is to extract some information from an indexed object in an object array in JSONIQ. Here's the code so far.
...ANSWER
Answered 2018-Sep-12 at 13:44I planned initially to iterate over an array of objects to print out the data within the objects. For JSONIQ, I discovered that I needed to parenthesize the array name which is book() in this case.
My code below should iterate over, the title, the author, and the price of the book.
QUESTION
Is it possible to print to console for debugging purposes in a JSONiq/Zorba script?
e.g.
...ANSWER
Answered 2018-May-23 at 06:28Yes: the trace
function serves this purpose. It can be called on any expression of which one needs to see the output, together with a label of your choice.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install JSONiq
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page