What are the differences between JSONiq and XQuery 3.1?

Viewed 1043

Both JSONiq and XQuery 3.1 extend XQuery 3.0 with support for JSON.

How do they differ?

2 Answers

I am a little disappointed in how XQuery 3.1 supports Json.

One of the basic requirements is to be fully compatible with Json syntax, which just likes XQuery compatible with XML syntax and JSONiq compatible with Json syntax, so that customers can start from existing Json files. A prolog is acceptable, if must explicitly enable Json-compatible syntax.

Unfortunately, in standard XQuery 3.1, you must write map{...} for Json object, true() for Json value true, false() for Json value false, and () for Json value null. Converting Json files into Json templates will be painful.

XQuery 3.1 supports interspersing strings for plain text templates. If converting Json files into plain text templates, you must handle XQuery return values carefully, b/c it does not care about Json data types and escape quoted strings.

Conclusion

JSONiq (when work on Json only) and XQuery with JSONiq extension (when work on both XML and Json) are better solutions for converting Json files into Json templates.

Related