Updates to "JSON encoding and decoding"

Erik Arvidsson erik.arvidsson at gmail.com
Thu Apr 12 11:35:11 PDT 2007


I'm starting to see more and more people using Doug's proposal which I
thought we all decided was dangerous to use and that we came to the
conclusion that toJSONString would only be used at the top level for
the serialization (and that it would be read only) and then the
serializer would check for toJSON on the objects in the object graph
as it serialized it.

something like this:

class Object {

  // returns the JSON string of the object
  private function internalToJsonString_(object : Object) : String {
    // the recursive calls needs to check for toJSON on every element
    // we also need to check for cycles and throw
    ...
  }


  final function getJSONString(this : Object) : String {
    if (object.toJSON is funtion(Object) : Object)
      return internalToJsonString_(object.toJSON());
    return internalToJsonString_(object);
  }
}

I therefore think it is important that we update the proposal page
before people starts to implement this.

Doug: Could you update the RFC as well?

-- 
erik



More information about the Es4-discuss mailing list