<s> from django . utils import simplejson <EOL> from django . forms . util import ErrorDict , ErrorList <EOL> class ErrorJSONEncoder ( simplejson . JSONEncoder ) : <EOL> """<STR_LIT>""" <EOL> def default ( self , o ) : <EOL> if issubclass ( o . __class__ , ErrorDict ) : <EOL> return dict ( o ) <EOL> if issubclass ( o . __class__ , ErrorList ) : <EOL> return list ( o ) <EOL> else : <EOL> return super ( ErrorJSONEncoder , self ) . default ( o ) <EOL> def dumps ( o ) : <EOL> return simplejson . dumps ( o , cls = ErrorJSONEncoder , default = str ) </s>
