joanllenas / ts.data.json

1.7kB JSON decoding library for Typescript
BSD 3-Clause "New" or "Revised" License
205 stars 16 forks source link

Optionally fail object decoder when encountering unknown keys #8

Closed Dremora closed 5 years ago

Dremora commented 5 years ago

My use case: I have 1600 JSON files with complex structure that I want to type. The way I want to approach this is by iteratively running the decoder, inspecting the first error message and extending the decoder. I don't know in advance which fields those JSON files have, I want the decoder to help me in finding this out. I thus want the decoder to fail whenever it encounters an unknown object key.

Similar option exists in tcomb-validation is called strict.

joanllenas commented 5 years ago

Hi @Dremora , sounds like a nice feature to add, it could be useful to others. Let me think about it and during the next few days, I'll try to implement it. Cheers!

fabb commented 5 years ago

Yes that would be a nice feature.

Awesome library by the way!

joanllenas commented 5 years ago

Closed via https://github.com/joanllenas/ts.data.json/pull/9 For some reason, standard-version did not create a minor release, just a patch release (0.2.1). Docs are here: https://github.com/joanllenas/ts.data.json#jsondecoderobjectstrict

Anyway, let me know if there are any issues. Cheers!