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

Re: [json] parseJSON

Expand Messages
  • Peter Michaux
    ... Calling it filter may cause a namespace problem? Peter
    Message 1 of 7 , Jan 10, 2007
    • 0 Attachment
      On 1/10/07, Douglas Crockford <douglas@...> wrote:
      >
      > The parseJSON method currently takes a filter function parameter. It
      > will be invoked for every name/value in the structure.
      > myData = text.parseJSON(function (key, value) { return
      > key.indexOf('date') >= 0 ? new Date(value) : value; });
      > The filtration mechanism is just a general purpose map function. It
      > could be exposed as a separate method and used independently. If we were
      > to do that, then it could be used like this:
      > myData = text.parseJSON().filter(function (key, value) { return
      > key.indexOf('date') >= 0 ? new Date(value) : value; });
      > Do you think a general purpose .filter method is useful? Should it be
      > added to ECMAScript?


      Calling it "filter" may cause a namespace problem?

      <URL: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter>

      Peter
    • Michael Schwarz
      It looks like the LINQ features in C# 3.0: http://tirania.org/blog/archive/2007/Jan-10.html ;) ... -- Best regards | Schöne Grüße Michael Microsoft MVP -
      Message 2 of 7 , Jan 11, 2007
      • 0 Attachment
        It looks like the LINQ features in C# 3.0:
        http://tirania.org/blog/archive/2007/Jan-10.html

        ;)




        On 1/10/07, Douglas Crockford <douglas@...> wrote:
        >
        >
        >
        >
        >
        >
        >
        > The parseJSON method currently takes a filter function parameter. It
        > will be invoked for every name/value in the structure.
        > myData = text.parseJSON(function (key, value) { return
        > key.indexOf('date') >= 0 ? new Date(value) : value; });
        > The filtration mechanism is just a general purpose map function. It
        > could be exposed as a separate method and used independently. If we were
        > to do that, then it could be used like this:
        > myData = text.parseJSON().filter(function (key, value) { return
        > key.indexOf('date') >= 0 ? new Date(value) : value; });
        > Do you think a general purpose .filter method is useful? Should it be
        > added to ECMAScript?
        >
        > [Non-text portions of this message have been removed]
        >
        >



        --
        Best regards | Schöne Grüße
        Michael

        Microsoft MVP - Most Valuable Professional
        Microsoft MCAD - Certified Application Developer

        http://weblogs.asp.net/mschwarz/
        http://www.ajaxpro.info/

        WPF/E: http://groups.google.com/group/wpf-everywhere

        Skype: callto:schwarz-interactive
        MSN IM: passport@...
      • Douglas Crockford
        Safari s regular expression engine performs horribly on regular expressions on large texts. Tobie Langel suggested a workaround for parseJSON by splitting the
        Message 3 of 7 , Jun 20, 2007
        • 0 Attachment
          Safari's regular expression engine performs horribly on regular
          expressions on large texts. Tobie Langel suggested a workaround for
          parseJSON by splitting the regular expression in three with no loss of
          security.

          http://json.org/json.js
        Your message has been successfully submitted and would be delivered to recipients shortly.