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

RE: [json] RSON 0.06 released

Expand Messages
  • Michael Schøler
    Hi Patrick, Is the ordering of the data elements irrelevant in RSON to JSON, or is the manual in error? For example, business logic could (in some cases)
    Message 1 of 4 , Mar 21, 2010
    • 0 Attachment
      Hi Patrick,



      Is the ordering of the data elements irrelevant in RSON to JSON, or is the
      manual in error? For example, business logic could (in some cases) depend on
      the sequence/ordering of two data elements.



      This may be a bit on the edge but consider for example:



      Action:

      Allocate: ScreenBuffer

      Draw: [10, 3, 203, 6]

      Deallocate: ScreenBuffer



      Or maybe more to the point:



      Transaction:

      Ensure: 1000.0

      Withdraw: 1000.0



      In your examples in the manual, the ordering of the resulting JSON is not
      compliant with the ordering of the RSON data, e.g.:



      George: …

      Sam: …

      Morrie: …



      becomes:



      {

      “Morrie”: …

      “George”: …

      “Sam” …

      }



      Best regards,

      Michael Schøler



      From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
      Patrick
      Sent: 21. marts 2010 18:40
      To: json@yahoogroups.com
      Subject: [json] RSON 0.06 released





      I am pleased to announce the release of RSON 0.06.

      The goal of the RSON project is to create a file format that is easy to
      edit, diff, and version control, that is a superset of JSON and smaller than
      YAML.

      I consider this release to be feature complete on the file format, and I
      believe the pure Python 2.x decoder (parser) to be production worthy (for
      users who do not need the speed of a C based decoder).

      The project is at:

      http://rson.googlecode.com/

      The manual with syntax examples is at:

      http://rson.googlecode.com/files/rson_0_06_manual.pdf

      Discussions at:

      http://groups.google.com/group/rson-discuss





      [Non-text portions of this message have been removed]
    • Patrick Maupin
      ... First of all, for sequences (JSON arrays; Python lists), the order is preserved. For hashes (JSON objects), by default Python dicts are used, which does
      Message 2 of 4 , Mar 21, 2010
      • 0 Attachment
        On Sun, Mar 21, 2010 at 1:43 PM, Michael Schøler <michael@...> wrote:
        > Hi Patrick,
        >
        >
        >
        > Is the ordering of the data elements irrelevant in RSON to JSON, or is the
        > manual in error? For example, business logic could (in some cases) depend on
        > the sequence/ordering of two data elements.
        >
        >
        >
        > This may be a bit on the edge but consider for example:
        >
        >
        >
        > Action:
        >
        >                             Allocate: ScreenBuffer
        >
        >                             Draw: [10, 3, 203, 6]
        >
        >                             Deallocate: ScreenBuffer
        >
        >
        >
        > Or maybe more to the point:
        >
        >
        >
        > Transaction:
        >
        >                             Ensure: 1000.0
        >
        >                             Withdraw: 1000.0
        >
        >
        >
        > In your examples in the manual, the ordering of the resulting JSON is not
        > compliant with the ordering of the RSON data, e.g.:
        >
        >
        >
        > George: …
        >
        > Sam: …
        >
        > Morrie: …
        >
        >
        >
        > becomes:
        >
        >
        >
        > {
        >
        >  “Morrie”: …
        >
        >  “George”: …
        >
        >  “Sam” …
        >
        > }
        >

        First of all, for sequences (JSON arrays; Python lists), the order is
        preserved. For hashes (JSON objects), by default Python dicts are
        used, which does not preserve the order. As with the Python json or
        simplejson decoders (which also use dicts by default and thus also do
        not preserve order), you can specify a function that receives the
        ordered pairs of key/values (or if you wish to use the enhanced syntax
        which allows nested keys, you can specify a function that receives
        tuples of (key, [key, ...] value])).

        So, by default, the order of key/value pairs in objects is not
        preserved. (Is it in JavaScript?) But you can override that default
        behavior if you wish to do so.

        Best regards,
        Pat
      • Michael Schøler
        ... Hi, Fair enough. No it isn t in JavaScript regarding object properties (or JSON for that matter). Only with regards to serialization and de-serialization
        Message 3 of 4 , Mar 21, 2010
        • 0 Attachment
          > First of all, for sequences (JSON arrays; Python lists), the order is
          > preserved. For hashes (JSON objects), by default Python dicts are
          > used, which does not preserve the order. As with the Python json or
          > simplejson decoders (which also use dicts by default and thus also do
          > not preserve order), you can specify a function that receives the
          > ordered pairs of key/values (or if you wish to use the enhanced syntax
          > which allows nested keys, you can specify a function that receives
          > tuples of (key, [key, ...] value])).
          >
          > So, by default, the order of key/value pairs in objects is not
          > preserved. (Is it in JavaScript?) But you can override that default
          > behavior if you wish to do so.
          >
          > Best regards,
          > Pat

          Hi,

          Fair enough. No it isn't in JavaScript regarding object properties (or JSON
          for that matter). Only with regards to serialization and de-serialization
          (and obviously for Array's). When you need it for some purpose on objects
          the trick is usually therefore to make an array and keep the
          ordinality/indexing info there for each desired ordered object property.

          However, you might just comment on this fact in your RSON manual (however
          clear and apparent it may be for some devs) ;-)

          Many are confused about this specific topic - and I catch it out of the
          corner of my eye nearly every time I come across it, because I have made a
          great deal of JSON to XML and back again - and in XML documents, ordinality
          matters (XPATH can use element indexes).

          Best regards,
          Michael Schøler
        Your message has been successfully submitted and would be delivered to recipients shortly.