Exemplo n.º 1
0
 def encode(self, data):
     """
     encode data as json
     """
     encoder = JSONEncoder()
     thunker = JSONThunker()
     thunked = thunker.thunk(data)
     return encoder.encode(thunked)
Exemplo n.º 2
0
 def decode(self, data):
     """
     decode the data to python from json
     """
     if data:
         decoder = JSONDecoder()
         thunker = JSONThunker()
         data =  decoder.decode(data)
         unthunked = thunker.unthunk(data)
         return unthunked
     else:
         return {}