in reply to
make duplicate JSON keys an error
Musing about this ... while it might be nice to be able to detect such an error in what the data-supplier gives us, it might also be necessary to anticipate the problem and compensate for it in some reasonable way ... i.e. associate an arrayref of values with the key, pushing values onto it in the order received. If the supplier is using an Unenlightened Language that is doing the wrong thing, we just might have to find a way to live with it. If we want to / have to, as we so often find that we must.
Our pragmatic situation just might be: “I realize that the incoming data is incorrect. I can’t do anything about it, because the supplier of these data is a Leviathan company that runs at a glacial pace, and I can’t wait two years for them to decide they won’t accept a trouble-ticket from us. Meanwhile, I must not lose data, especially without knowing if or that I did.”
Over the years, I have dealt with a number of data-supplier situations where they “just switched to JSON,” often apparently writing their own code or template to do it, and they simply treated it “like XML/SOAP,” which does permit an arbitrary number of identically-named groups to appear in any container. They just did it that way, and fixing their code is not on their radar and never will be.