Login

Tag "encoder"

Snippet List

JSON Decimal encoder

Python json module or simplejson don't support Decimals out of the box. Here's an encoder that casts Decimals into floats and then displays them in desired format.

  • json
  • decimal
  • encoder
Read More

Django newforms ExtJS JSON Encoder

This is a subclass of Django's built-in JSONEncoder that adds the ability to output form and field objects as ExtJS-compatible config objects. Simple example: from django.utils import simplejson json = { 'data': [], 'success': True, 'metaData': { 'fields': SFY09RDOForm(), 'root': 'data', 'successProperty': 'success' }, } return HttpResponse(simplejson.dumps(json, cls=ExtJSONEncoder)) Where SFY09RDOForm is a subclass of django.forms.Form. 6/20/2008: Updated to pass on the help_text parameter (useful in combination with this override in ext: http://extjs.com/forum/showthread.php?t=36642)

  • json
  • ext
  • encoder
  • extjs
Read More

2 snippets posted so far.