Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: Fine-tuning your REST service
Lecture: JSON and XML rendering

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We already know that Eve responses are automatically rendered as Json or xml depending on the request accept header. With Json being the default
0:12 eventually you might decide to disable the support for one of the two renderers.
0:19 You simply go to the settings file and set either xml or Json to false, they are both true by default, you can't of course switch both of them off
0:33 otherwise your API won't be able to return any value to the clients. Also remember that in any case inbound documents are always going to be Json
0:44 even if you've disabled Json rendering in your responses. Speaking of Json, you might not know that the Json format is not ordered,
0:55 which means that every time you send the same request to the server you might get of course the same keys but in different orders every single time,
1:04 if you don't like this behavior, you can actually fix that by setting the Json sort key option to true, if you do this— let me turn Json on again,
1:22 if you set the Json sort keys to true, whenever you send a request, you are always going to get back keys in the same order.
1:36 Another fairly frequent feature request is support for custom accept headers or I should say for custom Json formats.
1:46 So what people want to do is still use the accept header and then set some custom value like csp-report,
1:57 which is a still a valid Json, it has just a different name. You can do that easily in Eve, you just set the Json request content types list
2:08 and update it to also support your custom format. The default is of course just this value here, but you can again extend it to support
2:21 whatever Json your legacy clients are supporting.

Talk Python's Mastodon Michael Kennedy's Mastodon