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

437Re: [json] Defining a standard for Recordsets in JSON

Expand Messages
  • Martin Cooper
    Jun 30, 2006
      On 6/30/06, todd_kingham <todd@...> wrote:
      >
      > Hello all,
      >
      > I've searched for an existing discussion on this subject and
      > couldn't find one, so I apologize if I'm duplicating an existing
      > thread.
      >
      > I'm quite curious to know how other developers/programmers feel
      > about defining a standard way to return recordsets, rowsets, query
      > beans, query objects, etc... Whatever you want to call them, they
      > appear to be a ubiquitous data-type in most programming languages
      > yet they seem to be addressed quite differently among different JSON
      > libraries. I'm speaking from a limited sampling of course (my own
      > implementation along with the two other ColdFusion implementations
      > found on json.org).


      A commercial toolkit I've used in the past uses the second form below. That
      works well because you can take one record and manipulate or use it without
      having to extricate it in any way from the surrounding context, as you would
      have to do in the first form below. I like having a record set be a set of
      records, instead of a funky construct that you have to fiddle with. It's
      more verbose, certainly, but unless your key names are long or you're
      transferring a great deal of data, I don't mind that, because of the clarity
      it brings to your code. (Also, the first form is more painful to create and
      update if what you started out with was a set of objects.)

      --
      Martin Cooper


      Below are a couple of examples of the same recordset being returned
      > by two different JSON libraries.
      >
      > CFJSON
      > =================================================================
      > {
      > "RECORDCOUNT":3,
      > "COLUMNLIST":"EMPLOYEEID,NAME",
      > "DATA":
      > {
      > "EMPLOYEEID":[1,2,3],
      > "NAME":["Nancy Davolio","Andrew Fuller","Janet
      > Leverling"]
      > }
      > }
      >
      >
      >
      >
      > JSON Serializer (for ColdFusion)
      > =================================================================
      > [
      > {
      > "EMPLOYEEID":1,
      > "NAME":"Nancy Davolio"
      > },
      >
      > {
      > "EMPLOYEEID":2,
      > "NAME":"Andrew Fuller"
      > },
      >
      > {
      > "EMPLOYEEID":3,
      > "NAME":"Janet Leverling"
      > }
      > ]
      >
      >
      >
      > I can't say I've experimented with every JSON library out there but
      > I'm pretty sure other libraries will return recordsets completely
      > differently then the two examples listed here.
      >
      > I suppose what I'm looking for here are 3 things:
      > 1. What are some examples of how other JSON libraries handle
      > recordsets?
      > 2. Does anyone else feel there is a need to come up with a
      > standard / guideline for recordsets?
      > 3. If there does need to be a standard what are some ideas of how
      > that should look?
      >
      >
      > Thanks in advance for everyone's input.
      > -Todd
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 3 messages in this topic