You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "Vincouux (via GitHub)" <gi...@apache.org> on 2023/12/11 08:28:24 UTC

[I] [Bug] Nested arrays decoding not working as expected [pulsar-client-python]

Vincouux opened a new issue, #172:
URL: https://github.com/apache/pulsar-client-python/issues/172

   ### Version
   OS: Ubuntu 22.04
   Python: 3.10.2
   Pulsar: pulsar-client==3.2.0
   
   ### Minimal reproduce step
   ```python3
   from pulsar.schema import JsonSchema, Record, Array, String
   
   class A(Record):
       a = String()
   
   class B(Record):
       b = Array(Array(A()))
   
   # Decode JSON data
   json_data = '{"b": [[{"a": "hello world"}]]}'
   decoded_data = JsonSchema(B).decode(json_data)
   
   # Access the nested objects
   nested_objects = decoded_data.b[0][0]
   print(type(nested_objects))
   print(nested_objects.a)
   ```
   
   ### What did you expect to see?
   ```
   <__main__.A object at 0x7fd1ecd07d00>
   hello world
   ```
   
   ### What did you see instead?
   ```
   <class 'dict'>
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   AttributeError: 'dict' object has no attribute 'a'
   ```
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Nested arrays decoding not working as expected [pulsar-client-python]

Posted by "Vincouux (via GitHub)" <gi...@apache.org>.
Vincouux commented on issue #172:
URL: https://github.com/apache/pulsar-client-python/issues/172#issuecomment-1849551038

   If it's intended, can someone indicate me how to achieve my goal. If it's not intended, probably the unit test should include this. Thanks a lot !


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org