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

Dynamic type information

Expand Messages
  • Atif Aziz
    JSON is limited to a few primitive types that serve quite well when it s enough to communicate all type information via documentation. For example, a date is
    Message 1 of 3 , Feb 1, 2006
    • 0 Attachment
      JSON is limited to a few primitive types that serve quite well when it's
      enough to communicate all type information via documentation. For
      example, a date is transmitted as a number and documented to be UTC
      milliseconds from January 1, 1970 or it's transmitted as a string that
      is documented to be using the ISO 8601 format. However, I am currently
      investigating ways to dynamically add type information on to a JSON
      stream in a JSON-ish manner. I have a couple of ideas that range from
      less-than-ideal hacks to things that eventually surpass an empirical
      keep-it-simple-stupid threshold. Has anybody tackled this problem and
      come up with an elegant solution before I go off reinventing the wheel?
      If it helps, I am looking less for a schema definition markup in JSON
      than I am for the equivalent of xsi:type from XML. And if I am walking
      down a dead-end road or beating a dead horse then let me know.



      Thanks,

      - Atif



      [Non-text portions of this message have been removed]
    • Michal Migurski
      ... JSON-RPC defines a pattern called class hinting, see section 3 of http://json-rpc.org/specs.xhtml. It s close... sort of. ... michal migurski- contact info
      Message 2 of 3 , Feb 1, 2006
      • 0 Attachment
        > JSON is limited to a few primitive types that serve quite well when
        > it's
        > enough to communicate all type information via documentation. For
        > example, a date is transmitted as a number and documented to be UTC
        > milliseconds from January 1, 1970 or it's transmitted as a string that
        > is documented to be using the ISO 8601 format. However, I am currently
        > investigating ways to dynamically add type information on to a JSON
        > stream in a JSON-ish manner. I have a couple of ideas that range from
        > less-than-ideal hacks to things that eventually surpass an empirical
        > keep-it-simple-stupid threshold. Has anybody tackled this problem and
        > come up with an elegant solution before I go off reinventing the
        > wheel?

        JSON-RPC defines a pattern called class hinting, see section 3 of
        http://json-rpc.org/specs.xhtml.

        It's close... sort of.

        ----------------------------------------------------------------
        michal migurski- contact info and pgp key:
        sf/ca http://mike.teczno.com/contact.html
      • Atif Aziz
        I guess I should have mentioned that I was aware of class hinting from JSON-RPC. Although fine in principle, I find the method slightly intrusive, verbose and
        Message 3 of 3 , Feb 1, 2006
        • 0 Attachment
          I guess I should have mentioned that I was aware of class hinting from
          JSON-RPC. Although fine in principle, I find the method slightly
          intrusive, verbose and heavy-duty for simple data types. It's heavy-duty
          because you end up paying a lot of memory and processing tax for parsing
          the entire construction passage only to throw away the objects and
          replace them via the actual intended one. Imagine an array of holiday.
          Each item would be a date expressed as strings using ISO 8601. For each
          item, you would therefore have something like this:

          {"jsonclass":["ISODate",["1999-12-31"]]}

          That's a lot baggage (1 hashtable, 2 arrays and 3 strings per item),
          don't you think?

          -----Original Message-----
          From: json@yahoogroups.com [mailto:json@yahoogroups.com] On Behalf Of
          Michal Migurski
          Sent: Wednesday, February 01, 2006 9:11 PM
          To: json@yahoogroups.com
          Subject: Re: [json] Dynamic type information

          > JSON is limited to a few primitive types that serve quite well when
          > it's
          > enough to communicate all type information via documentation. For
          > example, a date is transmitted as a number and documented to be UTC
          > milliseconds from January 1, 1970 or it's transmitted as a string that
          > is documented to be using the ISO 8601 format. However, I am currently
          > investigating ways to dynamically add type information on to a JSON
          > stream in a JSON-ish manner. I have a couple of ideas that range from
          > less-than-ideal hacks to things that eventually surpass an empirical
          > keep-it-simple-stupid threshold. Has anybody tackled this problem and
          > come up with an elegant solution before I go off reinventing the
          > wheel?

          JSON-RPC defines a pattern called class hinting, see section 3 of
          http://json-rpc.org/specs.xhtml.

          It's close... sort of.

          ----------------------------------------------------------------
          michal migurski- contact info and pgp key:
          sf/ca http://mike.teczno.com/contact.html






          Yahoo! Groups Links
        Your message has been successfully submitted and would be delivered to recipients shortly.