Question

Does FME (fully) support the JSONiq XQuery extension?

  • 28 November 2021
  • 0 replies
  • 4 views

Badge +3

When dealing with JSON data, I sometimes like to use the JSONiq XQuery extension to manipulate JSON data a bit more directly. For example to be able to directly query for only relevant data (see e.g. this question), or directly setting list attributes for portions JSON without the overhead of fragmenting/flattening the entire JSON structure (see e.g. this question).

 

I've been quite happy with the flexibility that the JSONiq XQuery extension seems to bring me, but as I'm using an XMLXQueryExtractor for this, this seems like a bit of a hack, and thus it might be that JSNOiq is not officially/fully supported.

 

For example, I also came across the situation where I wanted to check if a JSON value was equal to null or not. At first I had a look at the JSONiq specification page. There in the Revision History (at the end), I found this line below Revision 1-1;

Removed the function jn:is-null() because it is redundant with the "eq" and "instance of" operators which support null.

 

Then, I found this page on JSONiq data types, and tried to replicate the data/item type checks shown in 'Example 4.4 Atomic types'. I started with the query '16 instance of integer', but that resulted in an error. But the query '16 instance of xs:integer' did work (inspired by the XQuery examples on instance of expressions at Table 11-4 of this source).

 

So initially I thought it was just a namespace thing, but unfortunately both the queries 'null instance of null' and 'null instance of js:null' provided errors (namespaces of JSONiq data/item types found from here).

 

But then maybe it's also just that I'm overlooking things. As you can see I'm also not really an expert here, and sometimes it also seems that I get a bit confused at the documentation/examples I found of JSONiq.

For example, when trying to replicate the check on object types of JSONiq using the query '{ "foo" : "bar" } instance of object' (see Example 4.6), I also got an error, whereas when I look at Example 3.1 of the JSONiq specification page, it seems that it is neccessary to add parentheses at this check, and surely the query '{ "foo" : "bar" } instance of object()' does provide me with the desired result.

 

So, sorry for the long introduction/examples. In short my question is simply as in the title; does FME (fully) support the JSONiq XQuery extension?

Maybe a kind of switch/mode is required to fully switch to JSONiq instead of regular XML XQuery?

 

If JSONiq is fully supported, I'm wonering if anyone can explain me how I can use the 'instance of' expression to test for null values (or strictly speaking to test for null atomic types)?

 

Kind regards,

 

Thijs

 

ps. I added some screenshots and the workspace itself to illustrate the examples I mentioned in this question.

imageimage 


0 replies

Be the first to reply!

Reply