Completed JSON importer. Exported from import matches original data, must be working

This commit is contained in:
Binh 2013-05-21 13:36:44 -05:00
parent 7f9e5dbf65
commit 03ce460181
3 changed files with 55 additions and 2 deletions

View file

@ -62,6 +62,21 @@ class Field(object):
'dataLength': len(data)
}
def fromJSON(self, o):
import re
self.__init__(
name=o['name'],
max_length=o['maxLength'],
required=o['required'],
)
if isinstance(o['value'], basestring) and re.match('^\d*\.\d*$', o['value']):
o['value'] = decimal.Decimal(o['value'])
self.value = o['value']
return self
class TextField(Field):
def validate(self):