Merge pull request #146 from michele-comitini/native_json_local_check

improved json validator to output meaningful error
This commit is contained in:
mdipierro
2013-07-22 12:40:36 -07:00
+3 -3
View File
@@ -355,11 +355,11 @@ class IS_JSON(Validator):
return None
try:
if self.native_json:
simplejson.dumps(value) # raises error in case of malformed json
simplejson.loads(value) # raises error in case of malformed json
return (value, None) # the serialized value is not passed
return (simplejson.loads(value), None)
except JSONErrors:
return (value, translate(self.error_message))
except JSONErrors, e:
return (value, translate(self.error_message) + ': '+ e.message)
def formatter(self,value):
if value is None: