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

json_parse.js

Expand Messages
  • Douglas Crockford
    json_parse.js is a JSON parser written in JavaScript without any use of RegExp. http://json.org/json_parse.js
    Message 1 of 4 , Mar 26, 2008
    View Source
    • 0 Attachment
      json_parse.js is a JSON parser written in JavaScript without any use
      of RegExp.

      http://json.org/json_parse.js
    • Jorge Chamorro
      Line 170 is an enigma : (var) value, // Place holder for the value function. As (var) value = f() is defined later on @line 230... does 170 really make
      Message 2 of 4 , Mar 27, 2008
      View Source
      • 0 Attachment
        Line 170 is an enigma :

        (var) value, // Place holder for the value function.

        As (var) value = f() is defined later on @line 230... does 170 really
        make any difference ?

        If it does, why ? how ? I can't figure it out.

        Please let me know : I'm "worried" about line 170 :-)

        Also, I wonder why did you "feel the need" to rewrite the parser
        without RegExps ?
        This one should run (much?) slower, I mean, vs the native speed of
        RegExps, or not ?
        Why/when would you choose one version over the other ?

        Thanks !
        --Jorge ChB.



        On Mar 27, 2008, at 12:47 AM, Douglas Crockford wrote:

        > json_parse.js is a JSON parser written in JavaScript without any use
        > of RegExp.
        >
        > http://json.org/json_parse.js
        >
        >
        >



        [Non-text portions of this message have been removed]
      • Douglas Crockford
        ... As a matter of discipline, I always declare things before I use them. ... Some people are distrustful of regular expressions. An implementation that does
        Message 3 of 4 , Mar 27, 2008
        View Source
        • 0 Attachment
          --- In json@yahoogroups.com, Jorge Chamorro <jorge@...> wrote:
          >
          > Line 170 is an enigma :
          >
          > (var) value, // Place holder for the value function.
          >
          > As (var) value = f() is defined later on @line 230... does 170 really
          > make any difference ?

          As a matter of discipline, I always declare things before I use them.

          > Also, I wonder why did you "feel the need" to rewrite the parser
          > without RegExps ?

          Some people are distrustful of regular expressions. An implementation
          that does not use regular expressions may be more easily ported to
          other languages.
        • Tatu Saloranta
          On Thu, Mar 27, 2008 at 1:56 AM, Jorge Chamorro wrote: ... You may well be right that a regexp based one is faster (given JS lack of
          Message 4 of 4 , Mar 27, 2008
          View Source
          • 0 Attachment
            On Thu, Mar 27, 2008 at 1:56 AM, Jorge Chamorro <jorge@...> wrote:
            ...
            > Also, I wonder why did you "feel the need" to rewrite the parser
            > without RegExps ?
            > This one should run (much?) slower, I mean, vs the native speed of
            > RegExps, or not ?
            > Why/when would you choose one version over the other ?

            You may well be right that a regexp based one is faster (given JS'
            lack of efficient string/char manipulation methods), but performance
            is one area where intuition often leads astray. One should not try to
            guess which is faster, but to measure.
            So it would be great to get a performance test to verify which is
            faster (and on which JS engines) and by how much.

            -+ Tatu +-
          Your message has been successfully submitted and would be delivered to recipients shortly.