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

RE: [json] questions about json and pattern matching

Expand Messages
  • Craig Boyd
    Not that particular syntax, but the basic idea (querying/filtering and result set in JSON) has been around for quite some time. The latest example I can think
    Message 1 of 3 , Jun 16, 2010
    • 0 Attachment
      Not that particular syntax, but the basic idea (querying/filtering and
      result set in JSON) has been around for quite some time. The latest example
      I can think of would be OData from Microsoft. http://odata.org .



      From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of Nic
      Volanschi
      Sent: Wednesday, June 16, 2010 1:07 PM
      To: json@yahoogroups.com
      Subject: [json] questions about json and pattern matching

      Hi,

      I would like to submit a couple of questions to the members of this
      group, as JSON tools designers and/or users:

      1. Are you aware of any JSON codec library that implements a form of
      pattern matching like this:

      var persons = json_parse(client_message);
      var subset = selectMatching(persons,
      "{name:{firstname:%f,lastname:%l},children:[{gender:'male',born:%b}|%_]}");

      where subset would end up as an array filtering the persons array and
      extracting the corresponding fields, e.g.
      [{f: "John", l:"Smith", b:1991},
      {f: "Matt", l:"Johnson", b:1978}]

      Or even simpler forms of matching, for one element at a time:

      var count = {de: 0, von: 0, van: 0};
      for(p in persons) {
      res = match(p, "{name:{firstname:/^(de|von|van)/}}"); // note the embedded
      regex
      if(res) count[p[0]]++; // increments count.de or count.von or count.van

      2. Would you find it useful to have such a matching support as a
      complementary library, aside a json codec?

      I'm asking these questions because I wrote a generic matching library
      for JavaScript and Java (http://myPatterns.free.fr/) and I wonder if
      this could help people using JSON, such as those writing Ajax
      applications, for instance.

      Thanks for any help/comments,
      Nic.





      [Non-text portions of this message have been removed]
    • Nic Volanschi
      Hi Craig, Thanks for this pointer, interesting stuff (I never heard about OData before). Nic.
      Message 2 of 3 , Jun 22, 2010
      • 0 Attachment
        Hi Craig,

        Thanks for this pointer, interesting stuff (I never heard about OData
        before).

        Nic.

        On Wed, 2010-06-16 at 16:25 -0500, Craig Boyd wrote:
        >
        > Not that particular syntax, but the basic idea (querying/filtering and
        > result set in JSON) has been around for quite some time. The latest
        > example
        > I can think of would be OData from Microsoft. http://odata.org .
        >
        > From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
        > Nic
        > Volanschi
        > Sent: Wednesday, June 16, 2010 1:07 PM
        > To: json@yahoogroups.com
        > Subject: [json] questions about json and pattern matching
        >
        > Hi,
        >
        > I would like to submit a couple of questions to the members of this
        > group, as JSON tools designers and/or users:
        >
        > 1. Are you aware of any JSON codec library that implements a form of
        > pattern matching like this:
        >
        > var persons = json_parse(client_message);
        > var subset = selectMatching(persons,
        > "{name:{firstname:%f,lastname:%l},children:[{gender:'male',born:%b}|%
        > _]}");
        >
        > where subset would end up as an array filtering the persons array and
        > extracting the corresponding fields, e.g.
        > [{f: "John", l:"Smith", b:1991},
        > {f: "Matt", l:"Johnson", b:1978}]
        >
        > Or even simpler forms of matching, for one element at a time:
        >
        > var count = {de: 0, von: 0, van: 0};
        > for(p in persons) {
        > res = match(p, "{name:{firstname:/^(de|von|van)/}}"); // note the
        > embedded
        > regex
        > if(res) count[p[0]]++; // increments count.de or count.von or
        > count.van
        >
        > 2. Would you find it useful to have such a matching support as a
        > complementary library, aside a json codec?
        >
        > I'm asking these questions because I wrote a generic matching library
        > for JavaScript and Java (http://myPatterns.free.fr/) and I wonder if
        > this could help people using JSON, such as those writing Ajax
        > applications, for instance.
        >
        > Thanks for any help/comments,
        > Nic.
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.