Wow, W3C at it's best again. Non-modular, non-negotiable, JSON it is, take it or leave it. Well fuck you W3C. Base64 encoded files? Seriously? What if my app workes better with msgpack encoded forms? Or with XML encoded? So you're going to support one particular serialization format, quite a horrible one, but that's subjective and that's the whole point. Every app has different needs and you should spec. out a system…
How would you deal with rendering arbitrary form encodings in the browser? A proposal adding support for form submission of arbitrary encodings could be valid, but it'd have to just be a single form input with the data included verbatim. This proposal allows regular HTML forms with multiple input elements, but submitting over JSON. I can't see how you could define that for arbitrary encodings without first defining h…
W3C HTML JSON form submission
91–100 of 103 posts
Re: W3C HTML JSON form submission
#92Let me say first of all that I'm glad they're working on standardizing this. When making REST APIs, I find HTML form scaffolds incredibly useful, but it means that you probably have to accept both JSON (because JSON is reasonable) and occasional form-encoding (because forms), leading to subtle incompatibilities. Or you have to disregard HTML and turn your forms into JavaScript things that submit JSON. Either way, the…
Think that's fair point, yup. Very easy to do unintentionally, and it's non-intuitive that it'll suddenly change the return type. It's not clear if this style is really necessary. Why not just use the indexed syntax in this case? I guess it may be the authors intention to mirror form encoded submissions, that would send all of these values to the server. I'd suggest raising the point on the issue tracker so that it a…
{
"fruit": ["apple"],
"bottle-on-wall": ["1", "2", "3"]
}
Then add attributes to explicitly give the structure. Since this is a browser spec we can add attributes. Here's the same form but with some attributes giving the explicit encoding.
{
"fruit": "apple",
"bottle-on-wall": [1, 2, 3]
}
Dynamically varying JSON structures by form names and number of form elements is definitely going to be a source of bugs and security problems.Re: W3C HTML JSON form submission
#93Earlier quoted context omitted.
I don't think multiple fields with the same name is designed to be a normal mode of operation. If you actually want an array, use the [] suffix. But if you have a bug which produces a form with multiple fields with the same name, what should it do? I can think of two strategies: last one wins and the proposal. Both are probably going to lead to things going wrong in the backend. At least with the proposal you: A) can…
do any server-side environments currently present an array/array-like structure from request parameters with duplicate names (and specifically without any kind of array indicator, like name[] in php requests for example)?
[0] https://jersey.java.net/ [1] https://jax-rs-spec.java.net/
Re: W3C HTML JSON form submission
#94I'm not sure whether to be heartened or concerned that the W3C is referencing the doge meme in its specifications... see Example 6.
Re: W3C HTML JSON form submission
#95Earlier quoted context omitted.
Nodes have multiple children. In this case, you can split the 's children into three: a "text node"; a node; and another text node. You'd end up with something like this: { p: [ { text: 'This is' }, { b: { text: 'bold' }}, { text: 'text.'} ] } Not that I don't agree with you -- my suggestion is pretty messy and doesn't even go into how we'd deal with tag attributes -- but it's doable.
This has to be pre-processed somehow, if people don't like writing HTML by hand, consider writing that.
This is
bold
text.
(which is a lot easier for a machine to parse, at least.)JSON and YAML are great for what they do: data serialization, but they're just not appropriate choices for text markup. You have to use the right tool for the job.
There was a time when the industry wanted to cram 100% of everything into XML, and that gave us XSLT, XAML, SOAP, etc. We don't want to go back to that, either.
Personally, I'm most fond of an extended Markdown syntax to replace HTML. But I'm not going to hold my breath waiting on web browser vendors to agree on such a syntax, so instead I have my HTTP server do the conversion to HTML for me.
But if you had to force it into JSON, then I would suggest using a different markup for inline elements, eg:
html
body
p: "This is [/italic/] text."
p: "This is [[google.com => a hyperlink.]]"Re: W3C HTML JSON form submission
#96Wow, W3C at it's best again. Non-modular, non-negotiable, JSON it is, take it or leave it. Well fuck you W3C. Base64 encoded files? Seriously? What if my app workes better with msgpack encoded forms? Or with XML encoded? So you're going to support one particular serialization format, quite a horrible one, but that's subjective and that's the whole point. Every app has different needs and you should spec. out a system…
Re: W3C HTML JSON form submission
#97Earlier quoted context omitted.
It lets you comment out a line without having to remove the trailing comma from the previous line. That'd be useful if JSON had comments. I've seen people do this in the SELECT portion of SQL queries too. Personally, I hate this.
> It lets you comment out a line without having to remove the trailing comma from the previous line That would only be an advantage above comma at the end on the last line. It really only moves the problem from the last line to the first one. Now you can't comment out the first line without removing a comma...
It can make resolving merges just a little bit easier.
Re: W3C HTML JSON form submission
#98I'm not sure whether to be heartened or concerned that the W3C is referencing the doge meme in its specifications... see Example 6.
Concerned. Memes are in-group signalling one notch above the crudest kind such as football chants, a few notches below the more sophisticated kind like quoting Shakespeare, but all ultimately with the potential to exclude and confuse - which is definitely the opposite of what a technical spec should be trying to do.
I'm not a fan, but I don't think we should make it out to be more than it really is.
Re: W3C HTML JSON form submission
#99Am I the only one who is worried about the fact that this is exponential in size? Will generate a request that is ~5MB.
Re: W3C HTML JSON form submission
#100Earlier quoted context omitted.
How would you deal with rendering arbitrary form encodings in the browser? A proposal adding support for form submission of arbitrary encodings could be valid, but it'd have to just be a single form input with the data included verbatim. This proposal allows regular HTML forms with multiple input elements, but submitting over JSON. I can't see how you could define that for arbitrary encodings without first defining h…
Eg: By referencing an encoder function using the standard on* attribute. Could be called onbeforesubmit=encodeMsgpack. This function would take a JS object, generated according to the W3C's JSON form spec, and return a pair of [string, arraybuffer]. String being the MIME content type, and arraybuffer containing the request body.