zorba-processor / zorba

Zorba - the NoSQL processor
http://zorba.io
Apache License 2.0
42 stars 16 forks source link

Object field selector not working #7

Closed mspiegel closed 7 years ago

mspiegel commented 7 years ago
$ zorba -v
Zorba NoSQL Query Processor, Version: 3.1.0
$ zorba -q '{"foo":"bar"}.foo'
(no URI):1,15: static error [err:XPST0003]: invalid expression: syntax error,
unexpected expression (missing comma "," between expressions?)
ghislainfourny commented 7 years ago

Hi Michael,

Zorba supports two parsers: JSONiq (more pleasant for JSON data), and XQuery (more pleasant for XML data). The default parser is XQuery. The differences are documented on this page.

In order to activate the JSONiq parser, you need to use the JSONiq header (jsoniq version "1.0";)before your query:

zorba -q 'jsoniq version "1.0"; {"foo":"bar"}.foo'

For completeness: object lookup is also possible with the XQuery parser, however the syntax is that of a function call:

zorba -q '{"foo":"bar"}("foo")'
mspiegel commented 7 years ago

Oops now I see this documented on the link provided and I also see it on https://github.com/ghislainfourny/jsoniq-tutorial. Thank you!