Added control when decoding JSON and return the appropriate error