When I pass around any parameters in GET or POST parameters I wrap them in base64. That makes a lot of escaping bugs go away (and adds a bit of "security by obscurity", as well as true security when combining the query with a random number, a sha256 hash of the parameters and a serverside secret).
Not that this matters to your overall point, but base64 isn't actually a valid format to use in a parameter as a base64 string can legally contain: '+', '/' and '=' which would be interpreted and corrupt the data. In the .Net world you'll want to use something like HttpServerUtility.UrlTokenEncode()/UrlTokenDecode() since it gives you a base64-like string with '+', '/' and '=' replaced or removed.
JSON in URLs
21–30 of 38 posts
Re: JSON in URLs
#22A JSON like syntax that is URL query compatible sounds like a great solution to me. Rison tried this approach a couple years back: https://github.com/Nanonid/rison
Re: JSON in URLs
#23I was hoping the article was proposing a better way of encoding Json as urls, e.g. using the characters that are allowed in place of curly braces etc and doing simple translation. E.g {"foo":"bar","baz":[]} becomes foo=bar&baz=&&
Re: JSON in URLs
#24We actually do something similar to this to make our application state (within limits) be reflected by the url and support navigation — both good things. The urls are horrible though and we're considering simply storing the state in a service and giving it a serial number (but this has its own issues). I was hoping the article was proposing a better way of encoding Json as urls, e.g. using the characters that are all…
Re: JSON in URLs
#25Re: JSON in URLs
#26Basically everything about the status quo is messed up.
JSON into parameters: bad.
JSON into request body: undefined with the GET method.
JSON into request body with POST: great, but we're not actually mutating anything, so it's bad practice and won't be cached by varnish/nginx + a barrage of other problems.
I really wish someone would take up on http://www.ietf.org/rfc/rfc3253 - like REPORT as an analogue to GET, just with a JSON request body. Hey, we as a community finally managed to get PUT and PATCH on track, why not this one?
Re: JSON in URLs
#27Re: JSON in URLs
#28Even this article's final conclusion is that this is a bad idea. Data within the URL also has a number of other issues including: - It is easier to leak (e.g. browser history, proxies, some browser extensions, etc). Very few things record HTTP POST parameters unless they're doing something evil, very many non-evil pieces of software record the full URL. - Users intentionally or inadvertently re-posting data is much m…
So for these deeper APIs, how many humans are accessing these?
And, most importantly, i don't believe the article was arguing against POST (in fact, it doesn't mention POST.. once). I believe the argument was for times when you are already using URLs to convey data, such as in a search query, that JSON might be a useful alternative to plain HTTP Params.
No?
Re: JSON in URLs
#29Once you get there, maybe base64url binary blobs are way more efficient and quite compact.
Re: JSON in URLs
#30What benefit do you give you API caller?
What benefits do you give browser / caller caching for GET?
It really feels like they needed to get some content out for some reason, and just found some post in some internal dropbox wiki and posted it. Maybe they posted a draft by accident? I dont know...