source: pyson/test/MyDeserializer.py@ 1206

Last change on this file since 1206 was 490, checked in by wouter, 19 months ago

#152 changed @JsonDeserialize deserialization argument from str to type. It now takes the class as argument. This is attempt to solve some resolvation issues

File size: 701 bytes
RevLine 
[490]1from pyson.Deserializer import Deserializer
2
3'''
4Deliberate mismatch between class and package name,
5we should be able to handle that.
6'''
7class ValueDeserializer2(Deserializer):
8 '''
9 Used in DeserializerTest
10 '''
11 def __hash__(self):
12 return hash(self.geta())
13 def deserialize(self, data:object, clas: object)-> object:
14 if type(data)!=str:
15 raise ValueError("Expected str starting with '$', got "+str(data))
16 # Note we can't create real object here because that would result
17 # in circular import. This is why
18 # custom Desearializers are usually defined in same module as the
19 # target object
20 return int(data[1:])
21
22
Note: See TracBrowser for help on using the repository browser.