6

I have the following code in my views:

def __init__(self, obj='', json_opts={}, mimetype="application/json", *args, **kwargs):
        content = simplejson.dumps(obj, **json_opts)
        super(JSONResponse, self).__init__(content, mimetype, *args, **kwargs)

Since simplejson is going to be deprecated, can i use this

content = json.dumps(obj, **json_opts)

or do I need to do more?

Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
Mirage
  • 30,868
  • 62
  • 166
  • 261
  • Did you test it? What was the outcome? – gecco Oct 22 '12 at 05:25
  • 1
    Possible duplicate: http://stackoverflow.com/questions/712791/json-and-simplejson-module-differences-in-python – K Z Oct 22 '12 at 05:29
  • Is simplejson going to be deprecated? – Pramod Oct 22 '12 at 05:35
  • @gecco actually have used that acrross the whole site and i have only tested few pages and its working fine, but i anot 100% sure that is ok across all parts – Mirage Oct 22 '12 at 05:36
  • @parmod https://docs.djangoproject.com/en/dev/releases/1.5/#system-version-of-simplejson-no-longer-used – Mirage Oct 22 '12 at 05:36

2 Answers2

5

Use python's json instead:

Django 1.5 release notes

import json
Max Gruzin
  • 1,143
  • 1
  • 15
  • 22
4

According to this answer, json is simplejson. However, according to this release note, there might be some incompatibilities depending on which version of simplejson you are currently using. Either way, you will want to replace simplejson with json at some point. Just make sure you test your code before pushing it out to production.

Community
  • 1
  • 1
Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55