[issue34721] json module loads function
Ammar Askar
report at bugs.python.org
Tue Sep 18 09:26:54 EDT 2018
Ammar Askar <ammar at ammaraskar.com> added the comment:
This is intentional, the parsed in JSON doesn't necessarily have to have an object at the root. This is also what allows you to do:
>>> json.loads("[]")
[]
This behavior is also consistent with browsers, try this in your browser's dev console:
> JSON.parse("123")
123
> JSON.parse('"123"')
"123"
> JSON.parse('[]')
[]
More technically, look at the JSON standard here: https://www.json.org/
As you can see, the root value is an "element", which is of type "value" surrounded by some whitespace. Values can be any of these:
value
object
array
string
number
"true"
"false"
"null"
----------
nosy: +ammar2
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34721>
_______________________________________
More information about the Python-bugs-list
mailing list