<s> from django import forms <EOL> from django . core . exceptions import ValidationError <EOL> from django . utils import simplejson as json <EOL> from philo . validators import json_validator <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> class JSONFormField ( forms . Field ) : <EOL> """<STR_LIT>""" <EOL> default_validators = [ json_validator ] <EOL> def clean ( self , value ) : <EOL> if value == '<STR_LIT>' and not self . required : <EOL> return None <EOL> try : <EOL> return json . loads ( value ) <EOL> except Exception , e : <EOL> raise ValidationError ( u'<STR_LIT>' % e ) </s>
