bob at redivi.com
Thu Oct 26 08:41:33 PDT 2006
On 10/26/06, Douglas Crockford <crock at yahoo-inc.com> wrote:
> Brendan Eich wrote:
> > On Oct 25, 2006, at 7:24 AM, Dave Herman wrote:
> >>> I thought you might mean that, but I don't see how to do it. We
> >>> can't declare a type for "the set of all valid JSON values". If we
> >>> take an
> >> Do we need to? If you can't detect it statically or express it as a
> >> type, you can still detect it dynamically.
> > Sure, and that's what Bob is proposing. We just didn't see it last week
> > at the face to face. The built-in encoder must produce a string, but the
> > customizable method can produce only a JSON value, instead of producing
> > an encoded substring that would then have to be validated by parsing.
> > Then the encoder can check the value for cycles, do standard stuff like
> > pretty encoding, etc.
> > Doug, what do you think?
> I think this is getting out of hand. What was originally intended was a
> convenient little serializer that would be a little faster and more
> convenient than the current json.js. Bob wants to turn it into a
> transformation engine. I think he should do all of his transformations
> method as the final step. I prefer to keep the standard simple, and let
> Bob do complicated on his side.
I think the current proposal is dangerous. I don't think it's an API
that people will use correctly. Having to generate an entirely new
object graph before encoding really bites for performance and ease of
You also over-estimate the difficulty of implementing a "toJSON"
method instead of "toJSONString". It's really not that hard,
seriously, I've written at least two JSON encoders that do it. It
sounds more like you don't want to change the spec for the sake of not
having to change it.
Also, I've NEVER seen a serialization protocol that does something
silly like toJSONString. If they offer transformations, it's always
guaranteed that you get valid output... and the only way to do that is
to allow the transformation to return a data structure instead of a
More information about the Es4-discuss