Skip to content
Snippets Groups Projects
Select Git revision
  • 01054f20925b92229402750979864f8d38a76916
  • master default protected
2 results

ujson_dumps_float.py

  • Eric Poulsen's avatar
    01054f20
    py/objdict: Quote non-string types when used as keys in JSON output. · 01054f20
    Eric Poulsen authored
    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.
    01054f20
    History
    py/objdict: Quote non-string types when used as keys in JSON output.
    Eric Poulsen authored
    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.