Improve validation of JSON inputs