properties

15 views
Skip to first unread message

Lloyd Hilaiel

unread,
May 19, 2009, 9:41:11 PM5/19/09
to json-query
How might properties be escaped in JSONQuery? Because dot '.' is
legal in a json property name, there must be a way to escape it, for
instance here are a couple documents that demonstrate the ambiguity:

{"foo.bar.baz": "bing"}
{"foo": { "bar": { "baz" : "boom" } } }

What does the JSONQuery "$.foo.bar.baz" return?

A similar issues arises with a left square bracket.

There seem to be two options, make all properties valid JSON strings
(hence, requiring quotes and following the escaping rules in json), or
make it a bit more sloppy and allow for the omission of the quote
where the first whitespace, left square brace, or dot would terminate
the string...

So '$."foo.bar.baz"' -> "bing"
and '$.foo."bar".baz" -> "boom"

thoughts?
lloyd

Kris Zyp

unread,
May 20, 2009, 10:32:58 AM5/20/09
to json-...@googlegroups.com, llo...@gmail.com

Following from JSONQuery's predecessor, JSONPath, I have used JavaScript
style properties to handle these cases in the Dojo implementation [1]
(which you are free to look at and utilize):
$["foo.bar.baz"] -> "bing"
$.foo.bar.baz -> "boom"

[1] http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/json/query.js

Kris

Reply all
Reply to author
Forward
0 new messages