所以我有,我想序列化JSON如何序列Python的字典,以JSON
{'someproperty': 0, 'anotherproperty': 'value', 'propertyobject': SomeObject(someproperty=0, anotherproperty=0)}
但json.dumps
拋出一個TypeError: SomeObject(someproperty=0, anotherproperty=0) is not JSON serializable
那麼如何才能正確我我的序列化的python字典一些Python字典?
即使SomeObject應該是json對象,您也不能擁有對象。像{'someproperty':0,'another property':'value','SomeJson':{'someproperty':0,'another property':0}} –