Is sending attributes as JSON in an POST/PUT request breaking REST?
TLDR: is PUT /users/1
with user="{name: 'John'}"
, as opposed to user[name]="John"
, OK?
I love REST. Recently, I find myself storing a lot of my data in client-side JavaScript objects. It seems converting them to form-parameters like
user[name] = "John", user[login] = "jdoe"
is unnecessary ugly, since they'll just be reconstructed at the server as something like
{user: {name: 'John开发者_运维问答', login: "jdoe"} }
Advice, Internet? Shall I have the frameworks do the conversion for me? Should I use JSON? Should I start using BSON instead, since it preserves types like Date? :)
As long as the parameters are in the request body (i.e. not sent as query parameters) and the content type is set appropriately, I don't see there being any problem with it, RESTfully.
精彩评论