mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-21 07:31:00 +00:00
1 line
4.9 KiB
JSON
1 line
4.9 KiB
JSON
[{"user_id": 2568, "stars": [], "topic_id": 43060, "date_created": 1312140976.364815, "message": "Linking to documentation from the error message is a great idea", "group_id": 8422, "id": 1760093}, {"user_id": 10771, "stars": [], "topic_id": 43060, "date_created": 1312141077.1699131, "message": "nice. fix your crappy data model in the API", "group_id": 8422, "id": 1760106}, {"user_id": 19005, "stars": [], "topic_id": 43060, "date_created": 1312141275.362463, "message": "As a stopgap at least, sure", "group_id": 8422, "id": 1760124}, {"user_id": 38905, "stars": [], "topic_id": 43060, "date_created": 1312141859.653583, "message": "Tastypie documentation: http://django-tastypie.readthedocs.org/en/latest/", "group_id": 8422, "id": 1760156}, {"user_id": 19005, "stars": [{"date_created": 1312141557.4787941, "user_id": 15476}, {"date_created": 1312144047.4505661, "user_id": 209}], "topic_id": 43060, "date_created": 1312141426.024899, "message": "You CAN return a 400 with a JSON body!", "group_id": 8422, "id": 1760137}, {"user_id": 19005, "stars": [{"date_created": 1312144041.1205449, "user_id": 209}], "topic_id": 43060, "date_created": 1312141307.2469051, "message": "And if you're built really consistent RESTful stuff, you can even auto-generate a lot of the documentation", "group_id": 8422, "id": 1760126}, {"user_id": 11035, "stars": [], "topic_id": 43060, "date_created": 1312142444.740104, "message": "It's like magic.", "group_id": 8422, "id": 1760203}, {"user_id": 209, "stars": [], "topic_id": 43060, "date_created": 1312144101.4897721, "message": "Well, maybe like magic, but only a few hundred lines of code, and great documentation. Demo seems like magic though", "group_id": 8422, "id": 1760331}, {"user_id": 209, "stars": [], "topic_id": 43060, "date_created": 1312513622.374182, "message": "@mitechie So, to fully answer your question, and a couple of the concerns that came up on twitter (@velociraptors, @jaaaarel thanks): \"Is it an acceptable practice to accept JSON and return Plain Text\" A: \"Yes, but document it\", Long A: \"Acceptable? sure, do what you want, but document it. 'great', I'd say no, probably not even 'good', I would favor the easiest route for you to pick a format (in your case json) and be consistant. json in, json out, or KVP in json out, whatever. Pick something, document it, and stay consistant.\n\nWhat's _really_great_ is when you start understanding the Content-Type and the Accept headers, and respond to the client in a meaningful way based on what they're giving you, and asking for respectively (again, I love django-tastypie for doing this well) \n\nDifferent endpoints returning different formats (no matter how well documented) for a single api will probably surprise some of your users. and (please correct me if I'm wrong) but this seems to be what @velociraptors was bringing up, if you have one API endpoint called \"bookmarks\" which returns a json list of bookmarks,", "group_id": 8422, "id": 1799137}, {"user_id": 209, "stars": [], "topic_id": 43060, "date_created": 1312513739.795346, "message": "\n[\n\t{\n\t\t\"url\": \"http://pyohio.org\",\n\t\t\"tags\": [\n\t\t\t\"responsive-design\", \"open-source\", \"django\", \"python\", \"kellycreativetech\"\n\t\t],\n\t\t\"plain_text\": \"/api/plain_text/14\",\n\t\t\"id\": 14,\n\t}\n]\n", "group_id": 8422, "id": 1799148}, {"user_id": 209, "stars": [], "topic_id": 43060, "date_created": 1312513775.6957591, "message": "but then you have /api/plain_text/14 _just_ return the plain text, and not a json representation of the plain text, it might be acceptable, but it might surprise your users, which isn't particularly fun.", "group_id": 8422, "id": 1799150}, {"user_id": 7372, "stars": [], "topic_id": 43060, "date_created": 1312544400.0301139, "message": "@issackelly thanks, I was working on my error codes and it seems that pyramid bypasses the renderer when you raise an HTTP exception. I have to do some manual tweaks to get the json in -> error -> json error message out to work. I just wanted to make sure that makes sense. Was a bit surprised that it didn't work with the framework ootb.", "group_id": 8422, "id": 1801261}, {"user_id": 7372, "stars": [], "topic_id": 43060, "date_created": 1312550012.2495079, "message": "Ok, I think I'm back to happy now. The problem is that I keep wanting to raise pyramid's http exceptions. Doing that bypasses the renderer/accepts setup. So rather than a context manager that raises an exception, things are moved to a decorator that will return the right error code/information. Now I can get json error messages out of my error responses in a nice enough way. I kept beating my head on getting a context manager to return something on behalf of the controller function call.", "group_id": 8422, "id": 1801658}, {"user_id": 19005, "stars": [], "topic_id": 43060, "date_created": 1312595260.0365751, "message": "Yeah, context managers aren't meant to do that. :) good for exceptions, not for return codes!", "group_id": 8422, "id": 1806960}] |