asolfre / appengine-rest-server

Automatically exported from code.google.com/p/appengine-rest-server
Other
0 stars 0 forks source link

JSON usage #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From a Json use perspective and I'm not a resource of this, But the Json 
approach is that you post an entity wrapped in it's kind name so

{'item':{'code':'9000'}}

And the server responds with a flat string of the key:

"ag9kZXZ-dGlsbGlmeS1hcGlyCgsSBGl0ZW0YSAw"

Which breaks the Json model. As the response is not Json.

Should the response not be

{item:{"key","ag9kZXZ-dGlsbGlmeS1hcGlyCgsSBGl0ZW0YSAw"}}

Json in Json out?

Would also be nice if in Python a setting can be added to force the server to 
use Json. or if the response could be forced in the url.

So;

items/json

Just some ideas that i think would enhance,

What do others think?

Original issue reported on code.google.com by ad...@tillify.com on 11 Nov 2012 at 4:25

GoogleCodeExporter commented 9 years ago
As mentioned in the "Getting Started" 
(http://code.google.com/p/appengine-rest-server/wiki/GettingStarted), the 
"Features" (http://code.google.com/p/appengine-rest-server/wiki/Features) and 
the examples 
(http://code.google.com/p/appengine-rest-server/source/browse/trunk/example.txt#
202), you can use query parameters to get back a structured key or the entire 
object.  additionally, if you use the "Accept:" header with just the json type, 
you will automatically get back the structured key response as well (as of the 
1.0.6 release i believe).

As for defaulting to always using json, see 
http://code.google.com/p/appengine-rest-server/issues/detail?id=23 .

Original comment by jahlborn@gmail.com on 11 Nov 2012 at 8:42

GoogleCodeExporter commented 9 years ago
Brilliant. My fault I assumed as I posted in json it would default to send back 
json. You are quite right by adding the header 'Accept': 'application/json' it 
returns a perfectly well formed response {"key": 
"ag9kZXZ-dGlsbGlmeS1hcGlyCgsSBGl0ZW0YaQw"}.

Really impressed.

Thank you.

Original comment by ad...@tillify.com on 11 Nov 2012 at 9:31