added JSON validation and 400 status code if not valid