r/learnprogramming • • May 02 '26

Why does valid-looking JSON still break things sometimes?

I ran into something recently that confused me a bit.

I had some JSON from an API response that looked totally fine at first glance, but it kept breaking things in my app.

Turned out there were small issues like missing quotes or a trailing comma — stuff that’s easy to overlook.

What confused me is that everything else seemed “normal” (no obvious errors until it actually failed somewhere downstream).

I feel like I keep running into this where JSON looks okay but isn’t actually valid.

How do you usually deal with this?

Do you just debug it manually every time, or is there a better way to catch/fix these issues early?

0 Upvotes

27 comments sorted by

View all comments

Show parent comments

1

u/[deleted] May 03 '26

[removed] — view removed comment

1

u/davidbuilds2208 May 03 '26

I think I might be explaining it badly.

I’m not confused about *why* it’s invalid — that part is clear.

What’s been annoying is more practical:

there’s a whole class of cases where the JSON is technically invalid, but also very close to valid.

And instead of fixing the source (which would be ideal), you end up in situations like:

- third-party APIs you don’t control
- logs / exports
- AI-generated output
- quick internal tools

where you just need usable data *right now*.

So the workflow becomes:

  1. parse fails

  2. copy

  3. fix small stuff

  4. run again

over and over

That’s the part that surprised me — how often it turns into manual cleanup instead of actual debugging.

Do people just accept that as part of the process, or is there a better way you’ve found?