RE: HTML JSON form submission

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