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

Re: [json] Esel, a JSON query and expression language

Expand Messages
  • Andrea Giammarchi
    I had a quick look into code and documentation. It is a nice experiment from parser point of view but for loop a part, it seems that at the end of the day, all
    Message 1 of 6 , Aug 21, 2009
    • 0 Attachment
      I had a quick look into code and documentation.
      It is a nice experiment from parser point of view but for loop a part, it
      seems that at the end of the day, all code purpose is to do something like
      this:

      function Esel(JSON, expression){
      with(typeof JSON === "string" ? eval("(" + JSON + ")") : JSON)
      with(Math)
      return expression.replace(/\${([^\}]*)}/g, function(match,
      code){
      return eval("(" + code + ")");
      });
      };

      Example

      var result = Esel(
      // pass JSON string or an object
      {
      "Image": {
      "Width": 800,
      "Height": 600,
      "Title": "View from 15th Floor",
      "Thumbnail": {
      "Url": "http://www.example.com/image/481989943",
      "Height": 125,
      "Width": "100"
      },
      "IDs": [116, 943, 234, 38793]
      }
      },
      'The square root of ${Image.Width} is ${sqrt(Image.Width)}.\n'+
      'The length of "${Image.Thumbnail.Url}" is
      ${Image.Thumbnail.Url.length}.\n'+
      'The value of "\\u0041" is "${\'\u0041\'}".\n'+
      'The length of the "Image.IDs" array is ${Image.IDs.length}.'
      );

      alert(result);

      Am I missing something about this Esel concept?

      Good work in any case, I do like the grammar parser.

      On Thu, Aug 20, 2009 at 6:00 AM, deadpixi.software <
      deadpixi.software@...> wrote:

      >
      >
      > Hello everyone,
      > Just wanted to post a message about an open source project of mine: Esel.
      > Esel is a powerful query and expression language designed to work with JSON
      > data (or any data exported to it from the hosting JavaScript application).
      >
      > Please check out http://www.deadpixi.com/esel for more information.
      >
      > Thanks,
      > Rob
      >
      >
      >


      [Non-text portions of this message have been removed]
    • deadpixi.software
      Howdy, Esel doesn t depend on anything other than Kouprey (included with the Esel distribution, or downloadable separately at http://www.deadpixi.com/kouprey).
      Message 2 of 6 , Aug 22, 2009
      • 0 Attachment
        Howdy,
        Esel doesn't depend on anything other than Kouprey (included with the Esel distribution, or downloadable separately at http://www.deadpixi.com/kouprey).

        It should be possible to use Esel with Java using the JavaScript interpreter included with Java 6, or by using Rhino on earlier versions of Java. This hasn't been tested, but I can't think of any reason why it wouldn't work.

        If you do end up using Esel embedded in a Java application, please let me know - I'd be very interested to hear your experiences.

        Thanks,
        Rob

        --- In json@yahoogroups.com, janwen <loujianwen1986@...> wrote:
        >
        > deadpixi.software wrote:
        > >
        > >
        > > Hello everyone,
        > > Just wanted to post a message about an open source project of mine:
        > > Esel. Esel is a powerful query and expression language designed to
        > > work with JSON data (or any data exported to it from the hosting
        > > JavaScript application).
        > >
        > > Please check out http://www.deadpixi.com/esel
        > > <http://www.deadpixi.com/esel> for more information.
        > >
        > > Thanks,
        > > Rob
        > >
        > >
        > can i use it with java?
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • deadpixi.software
        (My apologies if this gets multi-posted; Yahoo was having issues.) Hello Andrea, Thanks for the feedback! I m definitely interested in any observations anyone
        Message 3 of 6 , Aug 22, 2009
        • 0 Attachment
          (My apologies if this gets multi-posted; Yahoo was having issues.)

          Hello Andrea,
          Thanks for the feedback! I'm definitely interested in any observations anyone may have. Thanks for taking the time to post this message.

          Part of the point of Esel was to avoid any use of eval() on the expression, to help enforce safety. Not "safety" from a malicious attacker standpoint, but so that someone entering an expression in, say, a web-based spreadsheet didn't say something like "i = 4" and pollute the global namespace or otherwise break something.

          This is also reflected in the ability to export a limited namespace and a limited set of functions to the Esel environment.

          Esel was also designed to be used with another project of mine, Jenner (http://www.deadpixi.com/jenner). Doing Jenner with evaluated JavaScript would have been somewhat difficult and far more conceptually dirty. Jenner requires better namespacing than native JavaScript can easily support, and also really needs far less verbosity than would be necessary if I went the eval()'d JavaScript route.

          The other goal was to have a language for JavaScript that filled roughly the same role as the UEL for Java.

          Hopefully this makes sense. It's Saturday and I'm not operating on a lot of sleep. :)

          Thanks again for your feedback. Please let me know if you have any other questions.

          Rob

          --- In json@yahoogroups.com, Andrea Giammarchi <andrea.giammarchi@...> wrote:
          >
          > I had a quick look into code and documentation.
          > It is a nice experiment from parser point of view but for loop a part, it
          > seems that at the end of the day, all code purpose is to do something like
          > this:
          >
          > function Esel(JSON, expression){
          > with(typeof JSON === "string" ? eval("(" + JSON + ")") : JSON)
          > with(Math)
          > return expression.replace(/\${([^\}]*)}/g, function(match,
          > code){
          > return eval("(" + code + ")");
          > });
          > };
          >
          > Example
          >
          > var result = Esel(
          > // pass JSON string or an object
          > {
          > "Image": {
          > "Width": 800,
          > "Height": 600,
          > "Title": "View from 15th Floor",
          > "Thumbnail": {
          > "Url": "http://www.example.com/image/481989943",
          > "Height": 125,
          > "Width": "100"
          > },
          > "IDs": [116, 943, 234, 38793]
          > }
          > },
          > 'The square root of ${Image.Width} is ${sqrt(Image.Width)}.\n'+
          > 'The length of "${Image.Thumbnail.Url}" is
          > ${Image.Thumbnail.Url.length}.\n'+
          > 'The value of "\\u0041" is "${\'\u0041\'}".\n'+
          > 'The length of the "Image.IDs" array is ${Image.IDs.length}.'
          > );
          >
          > alert(result);
          >
          > Am I missing something about this Esel concept?
          >
          > Good work in any case, I do like the grammar parser.
          >
          > On Thu, Aug 20, 2009 at 6:00 AM, deadpixi.software <
          > deadpixi.software@...> wrote:
          >
          > >
          > >
          > > Hello everyone,
          > > Just wanted to post a message about an open source project of mine: Esel.
          > > Esel is a powerful query and expression language designed to work with JSON
          > > data (or any data exported to it from the hosting JavaScript application).
          > >
          > > Please check out http://www.deadpixi.com/esel for more information.
          > >
          > > Thanks,
          > > Rob
          > >
          > >
          > >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • deadpixi.software
          (violating my own convention and replying to myself) The other advantage of Esel over eval() d JavaScript is Esel s text templating abilities. For example, you
          Message 4 of 6 , Aug 22, 2009
          • 0 Attachment
            (violating my own convention and replying to myself)

            The other advantage of Esel over eval()'d JavaScript is Esel's text templating abilities. For example, you can say things like this:

            Hello, ${name}!

            Jenner (mentioned below) extends these text templating capabilities to entire web pages.

            (okay, I'm done. No more replying to myself.)

            --- In json@yahoogroups.com, "deadpixi.software" <deadpixi.software@...> wrote:
            >
            > (My apologies if this gets multi-posted; Yahoo was having issues.)
            >
            > Hello Andrea,
            > Thanks for the feedback! I'm definitely interested in any observations anyone may have. Thanks for taking the time to post this message.
            >
            > Part of the point of Esel was to avoid any use of eval() on the expression, to help enforce safety. Not "safety" from a malicious attacker standpoint, but so that someone entering an expression in, say, a web-based spreadsheet didn't say something like "i = 4" and pollute the global namespace or otherwise break something.
            >
            > This is also reflected in the ability to export a limited namespace and a limited set of functions to the Esel environment.
            >
            > Esel was also designed to be used with another project of mine, Jenner (http://www.deadpixi.com/jenner). Doing Jenner with evaluated JavaScript would have been somewhat difficult and far more conceptually dirty. Jenner requires better namespacing than native JavaScript can easily support, and also really needs far less verbosity than would be necessary if I went the eval()'d JavaScript route.
            >
            > The other goal was to have a language for JavaScript that filled roughly the same role as the UEL for Java.
            >
            > Hopefully this makes sense. It's Saturday and I'm not operating on a lot of sleep. :)
            >
            > Thanks again for your feedback. Please let me know if you have any other questions.
            >
            > Rob
            >
            > --- In json@yahoogroups.com, Andrea Giammarchi <andrea.giammarchi@> wrote:
            > >
            > > I had a quick look into code and documentation.
            > > It is a nice experiment from parser point of view but for loop a part, it
            > > seems that at the end of the day, all code purpose is to do something like
            > > this:
            > >
            > > function Esel(JSON, expression){
            > > with(typeof JSON === "string" ? eval("(" + JSON + ")") : JSON)
            > > with(Math)
            > > return expression.replace(/\${([^\}]*)}/g, function(match,
            > > code){
            > > return eval("(" + code + ")");
            > > });
            > > };
            > >
            > > Example
            > >
            > > var result = Esel(
            > > // pass JSON string or an object
            > > {
            > > "Image": {
            > > "Width": 800,
            > > "Height": 600,
            > > "Title": "View from 15th Floor",
            > > "Thumbnail": {
            > > "Url": "http://www.example.com/image/481989943",
            > > "Height": 125,
            > > "Width": "100"
            > > },
            > > "IDs": [116, 943, 234, 38793]
            > > }
            > > },
            > > 'The square root of ${Image.Width} is ${sqrt(Image.Width)}.\n'+
            > > 'The length of "${Image.Thumbnail.Url}" is
            > > ${Image.Thumbnail.Url.length}.\n'+
            > > 'The value of "\\u0041" is "${\'\u0041\'}".\n'+
            > > 'The length of the "Image.IDs" array is ${Image.IDs.length}.'
            > > );
            > >
            > > alert(result);
            > >
            > > Am I missing something about this Esel concept?
            > >
            > > Good work in any case, I do like the grammar parser.
            > >
            > > On Thu, Aug 20, 2009 at 6:00 AM, deadpixi.software <
            > > deadpixi.software@> wrote:
            > >
            > > >
            > > >
            > > > Hello everyone,
            > > > Just wanted to post a message about an open source project of mine: Esel.
            > > > Esel is a powerful query and expression language designed to work with JSON
            > > > data (or any data exported to it from the hosting JavaScript application).
            > > >
            > > > Please check out http://www.deadpixi.com/esel for more information.
            > > >
            > > > Thanks,
            > > > Rob
            > > >
            > > >
            > > >
            > >
            > >
            > > [Non-text portions of this message have been removed]
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.