yciabaud opened a new issue #3916: Serialization error when encoding schema 
with subrecords in python client
URL: https://github.com/apache/pulsar/issues/3916
 
 
   It seems that the schema support in the client 2.3.0 on python 3.7 is not 
working with subrecords.
   
   This example produces an error when encoding ():
   
   > "TypeError: Object of type MySubRecord is not JSON serializable"
   
   ```python
   import json
   from pulsar.schema import Record, String, JsonSchema
   
   def test_complex():
       class MySubRecord(Record):
           a = String()
   
       class Example(Record):
           sub = MySubRecord() # Test with instance
   
       r = Example(sub = MySubRecord( a = 'string' ))
       assert r.sub.a == 'string'
   
       s = JsonSchema(Example)
   
       # Produces "TypeError: Object of type MySubRecord is not JSON 
serializable"
       data = s.encode(r)
   
       assert json.loads(data)['sub']['a'] == 'string'
   ```
   Is there something I missed in the implementation? I tested with 
`AvroSchema` with no success.
   
   I expected the client to use a custom encoder that would have encoded the 
subrecord.
   
   What do you think?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to