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

Re: RE�: [json] __jsonclass__ hinting

Expand Messages
  • Shawn Silverman
    ... Just some thoughts.. I was experimenting with different ways to name things and came up with these: 1) Name the anonymous members using some sort of
    Message 1 of 5 , Jul 27, 2006
    • 0 Attachment
      > new element names. All the objects in JSON are anonymous, you just have:
      >
      > {
      > "firstName":"Joe",
      > "age":22,
      > }
      >
      > As soon as you have any non-trivial data structure (even just a
      > Hashtable of objects), you need a __jstype mechanism. This need is
      > much greater in JSON than xsi:type is in Xml.
      >
      > I don't agree with your arguments for why a type hint would never take
      > off: Everyone working with JSON in typed languages is adding some kind
      > of type hinting, the need for this is very apparent.

      Just some thoughts.. I was experimenting with different ways to name things and came up
      with these:

      1) Name the anonymous members using some sort of extended syntax.

      <Person>{
      "name": "Fred",
      "age":22
      }

      2) Alternatively, allow one of these inside an object:

      {
      <Person>,
      "name": "Fred"
      }

      3) JSON already has a way to do this (sort of):

      {
      "Person":{ "name":"Fred", "age":22 }
      }

      4) This could be extended:

      {
      "Person":{ "name":"Fred", "age":22 }
      "isInstance":true
      }

      Or we could have "isClass", etc.

      5) This could be used to define types instead:

      <Person>{
      "property":"name",
      "property":"age"
      }

      6) This could be shrunk:

      <Person>["name", "age"]

      7) Or:

      <Person>[{"name":"string"},{"age":number}]

      etc...

      I think of JSON more as the "lexing" layer with a few extra types, and then the meaning is
      tacked on by some sort of external program or schema.

      Just some random thoughts on the subject...

      -Shawn
    Your message has been successfully submitted and would be delivered to recipients shortly.