Trim data before JSON parsing