improved json validation and error message format