861Re: [json] JSONPath
- Sep 5, 2007On 8/28/07, Stefan Gössner <stefan@...> wrote:
> In the current process to improve JSONT I implemented a lightweightI have a comment about the syntax. It is extremely easy to implement a
> component JSONPath, which compares a lot to XPath.
> Comments are welcome .. thanks.
JSON parser because the syntax is simple. In not only looks good, it
is designed to be easy and good to implement.
For example, a string starts with a double-quote and ends with a
double-quote. So, when parsing a string there is only one character
that can end it. It makes the implementation trivial and fast.
The proposed syntax of JSONPath is not bad but a bit too ambivalent in
First, there is a choice of notation. It is simpler to select one and
stick to that.
And then the syntax is a bit more difficult than it should be.
The first syntax:
To end parsing a component you need to look for either a dot, an
opening square bracket or the end of line or the end of file
The bracket notation is easier.
To find the end of a component is easy, it ends with a single quote.
However there is another thing: after you have parsed an opening
bracket, you need to peek ahead at the following character to know if
it is a number or a string that follows.
Also, since json doesn't use single quotes but double quotes only, I
would use double quote to make it more similar. It might also make it
possible to reuse code in various json implementations.
My idea is the following syntax.
Just my two cents,
- << Previous post in topic Next post in topic >>