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

RE: [json] RSON 0.06 released

Expand Messages
  • 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 1 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.