open-contracting / ocdskit

A suite of command-line tools for working with OCDS data
https://ocdskit.readthedocs.io
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

indent: Unexpectedly removes content #182

Closed duncandewhurst closed 2 years ago

duncandewhurst commented 2 years ago

I happened upon some unexpected behaviour when I tried to indent a file that contained non-unique keys under /definitions/Award.

To reproduce:

curl -LOJ https://gist.github.com/duncandewhurst/848ac5dc8bd101ead02badd188898281/raw/f4b6f5e0760ddd8a8efb0ee18d3aa5561d61fc02/release-schema.json
ocdskit indent release-schema.json

Result: one of the properties keys under /definitions/Award is removed.

jpmckinney commented 2 years ago

Hmm, any software that reads and writes JSON is very likely to remove duplicate keys, because the internal representation is typically a dictionary, which cannot have duplicate keys. We'd need to write our own data structure. However, such inputs are rare, and generally JSON with duplicate keys is discouraged (e.g. RFC 7493). So, I'll mark this as wontfix.