[whatwg] Fwd: Form Serialization Idea

On 9/20/07, Asbj?rn Ulsberg <asbjorn at ulsberg.no> wrote:
> On Tue, 11 Sep 2007 22:22:55 +0200, Garrett Smith <dhtmlkitchen at gmail.com>
> wrote:
>
> > interface HTMLFormElement {
> >   string getDataSetString(); raises FileException
> >   string toJSONString(); raises FileException
> > };
>
> I like the idea, but not this concrete namning proposal. Can't
> 'toString()' be overloaded to accommodate this requirement for the
> HTMLFormElement? I'm not quite sure how the overload should look like, but
> I think this variable information fits better in an argument to a method
> than in the method name itself. Thus, I'd rather see:
>
Can't overload in JS. There isn't any toString on HTMLFormElement.
Having a parameterized toString wouldn't really make sense, either.

You can't override toString because it isn't guaranteed to be
available on host objects.

toString is useful for examining an element's state.

Host objects are not quite javascript objects, so it wouldn't be an
override of Object.prototype. AFAIK, Host objects are not req'd to
support Object.prototype.

In Gecko, these host objects are either very well duck typed, or they
are integrated into the JS engine well enough as to make them nearly
indistinguishable. In JScript, host objects are not quite so well duck
typed. You cannot, for example, say document.body.appendChild.call(
document.body, node ). And try document.body.toString() that is really
weird.

document.body.toString().toString().toString();


>    HTMLFormElement.toString('application/json');
>

How could JSON form serialization work with data: on HTML 5? Is it
something that could be integrated?

How about using a mime type for the JSON and put that on the form? I
think someone mentioned this over at the HTML 5 WG list.

This might be more suitable to have the JSON separated from the data
serialization.


> I'm not quite sure what getDataSetString() would return, though. Could you
> elaborate?
>
A serialized Data Set, just like what you see when you submit a form
-- the query string in a get or the post body in a POST.

I've also got an idea for getting the URI into a JSON format, via a
Map.<String, [String]> -- that's a map of Arrays where the arrays
contain only strings and the keys are strings.

> --
> Asbj?rn Ulsberg           -=|=-        asbjorn at ulsberg.no
> ?He's a loathsome offensive brute, yet I can't look away?
>


--
Programming is a collaborative art.

Received on Saturday, 22 September 2007 14:18:23 UTC