On Sep 25, 2007, at 4:20 PM, Andrew Red wrote:
> > To explain the subject line, I believe, the concept of JSON strings > should be described by the following formula: > > eval(obj.toJSON()) -> obj, > > i.e. toJSON methods should return such a string from an object that if > evaluated, the result to be identical to that original object. JSON is not the same thing as Javascript serialization. JSON is designed to be a language-independent object serialization for data-interchange that just happens to eval() in Javascript. If you understand the JSON spec [1], you'll understand why what you're asking for can't (won't) be done. In order to maintain its cross-language data-interchange capability, JSON supports only types that are common across nearly all programming languages: bools, strings, numbers, null, arrays, and objects/hashes/dictionaries/whatever-you-wanna-call-em. NaN is uncommon, as is a basic Date type. The Element type could be partially serialized as an object (i.e. key/value pairs)--but it was, I suspect, a conscious choice to not convert elements to JSON strings. (Functions too aren't serialized by Protoype's JSON implementation.) If you want to build your own custom serialization for those types as a separate library, no one here will complain. Personally, I'm against implementing these type into the core. TAG 1. http://json.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---
