import jsonpickle class Subclass(object): subclass_value=10 def my_fun(self): print "this is myfun from Subclass" class MainClass(object): mainclass_data='This is main class data' mainclass_value=5 sc=Subclass() obj=MainClass() pickle=jsonpickle.encode(obj,max_depth=1) #Here I set max_depth, so it will not recurse unpickleObject=jsonpickle.decode(pickle) #deeper than 'max_depth' steps into the object unpickleObject.sc.my_fun() print unpickleObject.mainclass_data
Output:
this is myfun from Subclass This is main class data
0 comments:
Post a Comment