XML Considered Harmful

Chris Angelico rosuav at gmail.com
Tue Sep 28 18:07:57 EDT 2021


On Wed, Sep 29, 2021 at 8:00 AM Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>   JSON is a kind of a subset of JavaScript for JavaScript
>   programmers. In Python, we can use JSON too, or we can
>   use Python itself.
>
>   When some external requirement to use a data exchange
>   notation like JSON should appear, one can still "translate"
>   such Python modules to JSON. This path is not blocked.

JSON exists as a transport mechanism because it is restricted and
can't contain malicious code. A Python equivalent would be
ast.literal_eval - a strict subset of the language but restricted for
safety. For trusted code, yes, straight code can be used.

(And ast.literal_eval, unlike JSON, can handle comments.)

ChrisA


More information about the Python-list mailing list