I'm working with a JSON schema and I'm trying to use the python JSON module to validate some JSON I output against the schema.
I get the following error, indicating that the Schema itself is not validating:
validation Traceback (most recent call last): File "/private/var/folders/jv/9_sy0bn10mbdft1bk9t14qz40000gn/T/Cleanup At Startup/gc_aicep-395698294.764.py", line 814, in <module> validate(entry,gc_schema) File "/Library/Python/2.7/site-packages/jsonschema/validators.py", line 468, in validate cls(schema, *args, **kwargs).validate(instance) File "/Library/Python/2.7/site-packages/jsonschema/validators.py", line 117, in validate raise error jsonschema.exceptions.ValidationError: ({'website': 'www.stepUp.com', 'bio': '', 'accreditations': {'portfolio': '', 'certifications': [], 'degrees': {'degree_name': [], 'major': '', 'institution_name': '', 'graduation_distinction': '', 'institution_website': ''}}, 'description': 'A great counselor', 'photo': '', 'twitter': '', 'additionaltext': '', 'linkedin': '', 'price': {'costtype': [], 'costrange': []}, 'phone': {'phonetype': [], 'value': '1234567891'}, 'facebook': '', 'counselingtype': [], 'logourl': '', 'counselingoptions': [], 'linkurl': '', 'name': {'first_name': u'Rob', 'last_name': u'Er', 'middle_name': u'', 'title': u''}, 'email': {'emailtype': [], 'value': ''}, 'languages': 'english', 'datasource': {'additionaltext': '', 'linkurl': '', 'linktext': '', 'logourl': ''}, 'linktext': '', 'special_needs_offer': '', 'company': 'Step Up', 'location': {'city': 'New York', 'zip': '10011', 'locationtype': '', 'state': 'NY', 'address': '123 Road Dr', 'loc_name': '', 'country': 'united states', 'geo': ['', '']}},) is not of type 'object' The validationError message indicates that what follows the colon is not a valid JSON object, I think, but I can't figure out why it would not be.
This JSON validates using a validator like JSON Lint if you replace the single quotation marks with double and remove the basic parentheses from either side.
The 'u' before the name has been flagged as a possible bug.
This is the code which outputs the name:
name = HumanName(row['name']) first_name = name.first middle_name = name.middle last_name = name.last title = name.title full_name = dict(first_name=first_name, middle_name=middle_name, last_name=last_name, title=title) name is inserted into the JSON using the following:
gc_ieca = dict( name = full_name, twitter = twitter, logourl = logourl, linktext = linktext, linkurl = linkurl, additionaltext = additionaltext, datasource = datasource, phone=phone, email = email, price = price, languages = languages, special_needs_offer = special_needs_offer, # location location = location, accreditations = accreditations, website = website ),