Add condition to JSON parsing to prevent errors