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

RE: HTML JSON form submission

From: Larry Masinter <masinter@adobe.com>
Date: Tue, 2 Dec 2014 03:47:38 +0000
To: "christophe@cgrand.net" <christophe@cgrand.net>, "public-html@w3.org" <public-html@w3.org>
Message-ID: <b42d2e62a8254cdfa5d208816801f857@DM2PR0201MB0960.namprd02.prod.outlook.com>
If you actually want to use JSON and not something “kind of like JSON but not quite”, then JSON (http://tools.ietf.org/html/rfc7159)  name/value pairs are unordered.



“  An object is an unordered collection of zero or more name/value
   pairs, where a name is a string and a value is a string, number,
   boolean, null, object, or array.”

Larry
--
http://larry.masinter.net


From: christophe.grand@gmail.com [mailto:christophe.grand@gmail.com] On Behalf Of Christophe Grand
Sent: Friday, November 28, 2014 1:45 AM
To: public-html@w3.org
Subject: HTML JSON form submission

It seems to me that the encoding algorithm http://www.w3.org/TR/html-json-forms/#the-application-json-encoding-algorithm depends on the ordering of inputs:

<form enctype='application/json'>
  <input name='foo' value='one'>
  <input name='foo' value='two'>
  <input name='foo[x]' value='three'>
</form>

{"foo": {"1": one", "2": "two", "x": "three"}}

<form enctype='application/json'>
  <input name='foo[x]' value='three'>
  <input name='foo' value='one'>
  <input name='foo' value='two'>
</form>

{"foo": {"": ["one", "two"], "x": "three"}

Sorting inputs before encoding them would make the algorithm simpler and clearly independent of the actual ordering.
Christophe

--
On Clojure http://clj-me.cgrand.net/

Clojure Programming http://clojurebook.com

Training, Consulting & Contracting http://lambdanext.eu/

Received on Tuesday, 2 December 2014 03:48:09 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:46:11 UTC