Best way to handle JSON in django

I get the JSON channel from the server, and today I convert it to a python object and therefore to a django view. Now we are updating our site. Where

  • client browser should parse json using jQuery
  • we will also have an adobe-air application that will directly use JSON.

However, I am not very interested in exposing my server server directly to the browser / adobe client. What's the best way to get through the django? any existing django application?

Regards, Django Rookie

+6
json django
source share
1 answer

You can use certain Django built-in elements , but I always found that SimpleJSON makes things easier.

Why? With direct serialization, you don’t want to show everything. Thus, using the built-in methods you need to cut a lot. With the help of SimpleJSON you built a voice recorder, fill it only with what you want to show, and pump it through the SimpleJSON lib. I find inclusion much safer than exception when it comes to exposing an API.

It is also much more versatile for using data, since your client will not be a django site, it is an AIR application with its own ideas on how to format data (even within a specification such as JSON, it may and may be differences).

Oh, and remember that there is no date type in JSON. (I only mention this because it has hurt me in the past)

Edit: (Thanks Cide) Django sends SimpleJSON to django.utils.simplejson , but it may not be forever. Despite this, you can download it separately from Pypi

+7
source share

All Articles