json-schema validation using validictory -


i getting following schema validation error using json schema , valdictory parser/validator. schema has been autogenerated using jsonschema.net (using same json data)

validictory.validator.fieldvalidationerror: value '{"bp": [{"category": "bp",  "created": "2013-03-08t09:14:48.148000", "value": 147.0, "day": "2013-03-11t00:00:00",   "value2": 43.0, "id": "dc049c0e-d19a-4e3e-93ea-66438a239712", "unit": "mmhg"}]}'   field '_data' not of type object 

code:

import json import validictory  data = json.dumps({'bp': [{'category': 'bp',          'created': '2013-03-08t09:14:48.148000',          'day': '2013-03-11t00:00:00',          'id': 'dc049c0e-d19a-4e3e-93ea-66438a239712',          'unit': 'mmhg',          'value': 147.0,          'value2': 43.0}]})   schema = {     "type":"object",     "properties":{         "bp": {             "type":"array",             "required":false,             "items":                 {                     "type":"object",                     "required":false,                     "properties":{                         "category": {                             "type":"string",                             "default": "bp",                             "required":false                         },                         "created": {                             "type":"string",                             "default": "2013-03-08t09:14:48.148000",                             "required":false                         },                         "day": {                             "type":"string",                             "default": "2013-03-11t00:00:00",                             "required":false                         },                         "id": {                             "type":"string",                             "default": "dc049c0e-d19a-4e3e-93ea-66438a239712",                             "required":false                         },                         "unit": {                             "type":"string",                             "default": "mmhg",                             "required":false                         },                         "value2": {                             "type":"number",                             "default":43,                             "required":false                         },                         "value": {                             "type":"number",                             "default":147,                             "required":false                         }                     }                 }           }     } }  validictory.validate(data,schema) 

i'm not familiar library, appear validating json text, not data - validator looking @ string, when schema says data should object.

what if instead of data = json.dumps({...}), had data = {...}?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -