Adding function to validate JSON objects directly