Start with correctness, not readability
If the JSON is invalid, pretty formatting is a distraction. A parser error usually means the real job is to find the missing comma, bad quote, extra character, or unmatched brace before you think about readability.