Parsing malformed JSON
peteris.rocks
Parsing malformed JSON
1–10 of 57 posts
Re: Parsing malformed JSON
#2Re: Parsing malformed JSON
#3Why? By whom? Did you complain loudly?
Re: Parsing malformed JSON
#4Malformed data is a scalability problem. Unusual failure modes from coding problems to random bit flips become inevitable as the data volume approaches infinity.
Re: Parsing malformed JSON
#5In an emergency, I might hand-edit it and make it right, but I'd absolutely insist that further files be in the correct format.
Re: Parsing malformed JSON
#6It's a neat trick, but not something I'd deploy into production. If I have to try to guess at what the customer is sending me, I'm not going to apply it to their account. In an emergency, I might hand-edit it and make it right, but I'd absolutely insist that further files be in the correct format.
Re: Parsing malformed JSON
#7Sometimes it's obvious what's wrong with malformed data you receive. A classic would be encoding errors.
But as soon as you start supporting broken components and APIs, you will never be able to unsupport it.
Prime example would be HTML. Granted, in the beginning, it was supposed to be written by humans but that was rather quickly not a major obstacle anymore and even a human can produce valid HTML with the help of a syntax checker.
Re: Parsing malformed JSON
#8Re: Parsing malformed JSON
#9Maybe I'm old fashioned - I'm all for flexible APIs and all, but to its point. If a customer sends rotten stuff, it should just be rejected with a 40x code.
At minimum, check to make sure it is proper JSON... I know that a lot of stream processors will put it into a queue and 200 right away and then process in the background, but I don't think that ensuring it is at least JSON and doesn't have a content size of more than X could be too intensive.
In this case, if the data was already accepted and you've got no choice but to deal with it, you've gotta do what you got to do. I've been there, and it ain't fun cleaning up a 900 GB JSON file.
Re: Parsing malformed JSON
#10Malformed data is a scalability problem. Unusual failure modes from coding problems to random bit flips become inevitable as the data volume approaches infinity.