Consider the following piece of code:
from PyQt5.QtCore import QJsonDocument
json = {
"catalog": [
{
"version": None,
},
]
}
QJsonDocument(json)
Under Python 3.7 and PyQt 5.14.2, it results in the following error at the last line:
TypeError: a value has type 'list' but 'QJsonValue' is expected
QJsonDocument
clearly support lists: QJsonDocument({'a': []})
works fine.
So, what's going on?
As it turns out, the
None
value is the reason. Although the docs clearly show thatQJsonDocument
supportsnull
values,None
is not supported in PyQt5:QJsonDocument({'a': None})
results inTypeError: a value has type 'NoneType' but 'QJsonValue' is expected
.The developers explained that that was an omission. They have resolved the issue.