W3C home > Mailing lists > Public > public-html@w3.org > April 2014

Re: Extension specification proposal: JSON form submission

From: Cameron Jones <cmhjones@gmail.com>
Date: Tue, 15 Apr 2014 15:00:09 +0100
Message-ID: <CALGrgesW8E7mOoDt=G4BYBcPi7kiowX5vtJUGnxUaAphpNFZSA@mail.gmail.com>
To: Robin Berjon <robin@w3.org>
Cc: "HTML WG (public-html@w3.org)" <public-html@w3.org>
Hi Robin,

Sorry for the delay in feedback on the proposal.

On Tue, Feb 25, 2014 at 4:00 PM, Robin Berjon <robin@w3.org> wrote:

> Hi all,
>
> I've put together a small and simple extension specification proposal.
> Essentially, it adds "application/json" as a potential enctype for HTML
> forms so that submitting JSON directly from forms becomes possible.
>

Looks really good and should make integration for some web services
simpler, especially given the desirability of JSON as a data encoding.


>
> Since just reproducing existing encodings in JSON syntax would bring
> relatively little value to the table, the JSON encoding makes it possible
> to generate structured JSON from forms based on simple conventions for the
> name attribute.
>


This is really good, however i note that you've defined what i'll describe
as 'unescaped bracket notation' as the convention for the name attribute.
The impact of having no escaping is that there will be an effective
restriction on the possible named values, for example the bracket or
quotation characters would not be representable.

Instead of this i suggest changing from a new convention for the name
attribute to standard JavaScript variable declarations (similar to event
handler content attributes), which could use both "bracket notation" or
"dot notation". The impact of this is that it would be simpler to decare
object properties using "dot notation", but would impose the necessity for
quotation marks when using non-numeric "bracket notation".

To illustrate by updating the example in the spec, using the different
notations would result in the following:

Dot Notation -

<form enctype='application/json'>
  <input name='wow.such.deep[3].much.power["!"]' value='Amaze'>
</form>

Bracket Notation -

<form enctype='application/json'>
  <input name='wow["such"]["deep"][3]["much"]["power"]["!"]' value='Amaze'>
</form>

I think this compounds benifit with using the same parsing rules across
content attributes, as well as providing the ability to declare object
property names with restricted characters which given JSON's flexibility in
this regard would be a shame not to support.

Thanks,
Cameron Jones
Received on Tuesday, 15 April 2014 14:00:36 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:16:38 UTC