Take Michael's argument a bit further (_exact_ encoding as a form  
would do it), and perhaps it might be acceptable that any nested  
arrays/hashes simply be JSON encoded and passed as a string.  It's a  
simple convention, with no edge cases.  Keys are preserved just as  
they are passed. Values are converted to strings immediately. The  
programmer has full control over how something will be passed, as s/ 
he can change the key/val pair at any time. Then allow for an  
onSerialize callback at the form level.

This problem didn't exist (at this volume level) until Prototype  
started serializing Forms as Hashes instead of query strings, which  
led to the problem of figuring out how to represent two inputs with  
the same name, which led to this serialization discussion.


TAG

On Mar 16, 2007, at 6:15 AM, Michael Peters wrote:

>
>
>
> Andrew Dupont wrote:
>>  We *are* trying to implement a serialization
>> method compatible with application/x-www-form-urlencoded
>
> I think this makes the situation very simple then. We need  
> Hash.toQueryString to
> behave *exactly* like a form of type application/x-www-form- 
> urlencoded. Forms
> *do not* add brackets to inputs so neither should this method. If  
> your backend
> requires brackets, then you need to add them to your form input  
> names as well as
> your hash key names. It would be strange if you had to do one and  
> not the other.
> I think it would be even worse to force users of non-bracketed  
> backends (J2EE,
> .Net, Perl, Python, etc) to have to change their backend code to  
> remove the
> brackets just because the client side JS library thinks they should  
> be there.
>
> I also think this method is becoming way more complicated than it  
> needs to be.
> This is not a generic data serialization method. We don't need to  
> deal with
> nested hashes or arrays inside arrays. If you want to serialize  
> arbitrary
> structures of arbitrary depths use JSON. It's really good at that.
>
> --
> Michael Peters
> Developer
> Plus Three, LP
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to