Operators in JSONQuery from JavaScript

73 views
Skip to first unread message

Jon Crosby

unread,
Apr 5, 2009, 11:30:07 PM4/5/09
to json-query
Kris,

I was looking at the JSONQuery docs for Persevere (http://
docs.persvr.org/documentation/jsonquery) and noticed there is a list
of JavaScript operators that include & and | (bitwise operators) but
not && and || (their logical counterparts). Is this an intentional
part of the spec or should we consider all valid JavaScript operators
to be valid JSONQuery operators?

Thanks,

Jon Crosby
http://joncrosby.me

Kris Zyp

unread,
Apr 6, 2009, 10:36:30 AM4/6/09
to json-...@googlegroups.com

I don't think all valid JS operators should be considered valid
JSONQuery operators as this would significantly increase the complexity
of JSONQuery implementations, at least if they are not using a
JavaScript engine. JSONQuery should be implementable in any language,
without requiring dependency on a full JavaScript capabilities. In
addition, in some situations where a JS engine is used, allowing all
operators may pose security risks as well (new, delete, and other
operators may have side-effects).

&& and || could be included, but with pure boolean operands there is no
difference in the resulting value (only a difference in execution of
operands, which I don't believe should be specified by a query
language). With non-boolean values, the logical operators' behavior
within JavaScript relies on the somewhat complicated boolean conversion
defined in JavaScript, and doesn't seem that valuable, IMO. It seems
like simplicity of grammar and syntax would be more valuable in this
case, but I am open to the idea that the logical operators are important
enough for inclusion.

Kris

Jon Crosby

unread,
Apr 6, 2009, 5:42:08 PM4/6/09
to json-...@googlegroups.com
I agree with you on keeping the query syntax simple. I just wanted to
make sure I was writing a good test suite that reflected the intent of
the document on the Persevere wiki. Thank you for the confirmation.

-Jon

>
>
> >
>
Reply all
Reply to author
Forward
0 new messages