Loading ...
Sorry, an error occurred while loading the content.

861Re: [json] JSONPath

Expand Messages
  • Henrik Hjelte
    Sep 5, 2007
    • 0 Attachment
      On 8/28/07, Stefan Gössner <stefan@...> wrote:

      > In the current process to improve JSONT I implemented a lightweight
      > component JSONPath, which compares a lot to XPath.
      > Comments are welcome .. thanks.

      I have a comment about the syntax. It is extremely easy to implement a
      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
      my opinion.

      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,
    • Show all 4 messages in this topic