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

1237Re: [json] Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)

Expand Messages
  • John Cowan
    Apr 27, 2009
    • 0 Attachment
      Tatu Saloranta scripsit:

      > > isNull(keyName)
      >
      > Would this mean it has to be null, or that it is nullable (allowsNull)?

      All these predicates are on the JSON object itself, because they are used
      before the object's type is known. So isNull("foo") means that there
      is a key "foo" in the JSON object value is null, and likewise with all
      the other primitives.

      > > isUndefined(keyName)
      >
      > does this mean "any type"? Sort of fallback, xml "any" type.

      No, it means that the specified key does not exist. I use the name
      "undefined" for cultural compatibility with JavaScript. There would be
      little point in an isAnyType predicate, because it would match anything
      *except* a missing key.

      > > isNumeric(keyName)
      >
      > perhaps also isInteger/integral?

      That's reasonable. In that case it would be useful to be able to map
      keys to integer as well, and perhaps standardized subtypes of integer too.

      > - [U]nion types that are not mappable to OO ("value can be
      > either an array or boolean"): this just means there are legal JSON
      > constructs for which no strict can be defined.

      Multiple inheritance is a subset of this (doesn't handle primitives).
      If type foobar is a subtype of types foo and bar, then effectively it
      is a union of them.

      One question: should the predicates and the maps do on-the-fly conversion?
      For example, if we specify a predicate of hasNumericValue("foo", 0),
      does "foo": "0" match, or do we require "foo": 0? Likewise, when
      mapping, if the map specifies bar->String and the object contains
      "bar": 123, does the bar field get "123", or is that an error?
      These questions are independent. I'd favor doing the conversions.

      --
      You let them out again, Old Man Willow! John Cowan
      What you be a-thinking of? You should not be waking! cowan@...
      Eat earth! Dig deep! Drink water! Go to sleep!
      Bombadil is talking. http://ccil.org/~cowan
    • Show all 8 messages in this topic