add type checking for JSON object