'Create a JSON representation of the form description.
Here\'s an example of the output:
"method": "post",
"submit_url": "/submit",
"fields": [
"name": "cheese_or_wine",
"label": "Cheese or Wine?",
"defaultValue": "cheese",
"type": "select",
"required": True,
"placeholder": "",
"instructions": "",
"options": [
{"value": "cheese", "name": "Cheese", "default": False},
{"value": "wine", "name": "Wine", "default": False}
"restrictions": {},
"errorMessages": {},
"name": "comments",
"label": "comments",
"defaultValue": "",
"type": "text",
"required": False,
"placeholder": "Any comments?",
"instructions": "Please enter additional comments here."
"restrictions": {
"max_length": 200
"errorMessages": {},
If the field is NOT a "select" type, then the "options"
key will be omitted.
Returns:
unicode'

def to_json(self):

    return json.dumps({'method': self.method, 'submit_url': self.submit_url, 'fields': self.fields}, cls=LocalizedJSONEncoder)
