当使用 jsonpickle 将对象序列化为 json 时,我注意到诸如 datetime 之类的对象被存储一次,然后将来的使用被存储为引用值,例如{"py/id":1}
. 是否可以存储实际值而不是参考?此引用似乎是隐藏的,并且在直接与数据库交互时会造成混淆。
前任。
class MyClass:
def __init__(self, eee):
now = datetime.datetime.utcnow()
self.ddd = now
self.ddd2 = now
self.ddd3 = now
json是
{"py/object": "__main__.MyClass", "py/state": {"ddd": {"py/object": "datetime.datetime", "__reduce__": [{"py/type": "datetime.datetime"}, ["B+IBFhYJCwx9oQ=="]]}, "ddd2": {"py/id": 1}, "ddd3": {"py/id": 1}, "eee": "fwaef"}}