Skip to content
Snippets Groups Projects
Commit 01054f20 authored by Eric Poulsen's avatar Eric Poulsen Committed by Damien George
Browse files

py/objdict: Quote non-string types when used as keys in JSON output.

JSON requires that keys of objects be strings.  CPython will therefore
automatically quote simple types (NoneType, bool, int, float) when they are
used directly as keys in JSON output.  To prevent subtle bugs and emit
compliant JSON, MicroPython should at least test for such keys so they
aren't silently let through.  Then doing the actual quoting is a similar
cost to raising an exception, so that's what is implemented by this patch.

Fixes issue #4790.
parent 8f55a8fa
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment