On Wed, Jun 10, 2020 at 4:09 PM J. Pic <jpic@yourlabs.org> wrote:
Good point, but then I'm not sure the decoder could be used for untrusted json anymore.

Another solution would be to generate a schema in a separate variable, which would represent the JSON structure with Python types.

For that there are many existing libraries. You might like one of my recent projects:

https://github.com/alexmojaki/datafunctions

or:

https://pydantic-docs.helpmanual.io/
https://github.com/lidatong/dataclasses-json
https://github.com/ltworf/typedload/