jsonpickle 中是否对此有任何支持?
例如,我存储和对象,他们修改其架构,然后尝试将其加载回来。
比如下面的变化,(属性加法)
import jsonpickle
class Stam(object):
def __init__(self, a):
self.a = a
def __str__(self):
return '%s with a=%s' % (self.__class__.__name__, str(self.a))
js = jsonpickle.encode(Stam(123))
print 'encoded:', js
class Stam(object):
def __init__(self, a, b):
self.a = a
self.b = b
def __str__(self):
return '%s with a=%s, b=%s' % (self.__class__.__name__, str(self.a), str(self.b))
s=jsonpickle.decode(js)
print 'decoded:', s
产生错误:
encoded: {"py/object": "__main__.Stam", "a": 123}
decoded: Traceback (most recent call last):
File "C:\gae\google\appengine\ext\admin\__init__.py", line 317, in post
exec(compiled_code, globals())
File "<string>", line 25, in <module>
File "<string>", line 22, in __str__
AttributeError: 'Stam' object has no attribute 'b'