Skip to content

[Bug] Nested arrays decoding not working as expected #172

Description

@Vincouux

Version

OS: Ubuntu 22.04
Python: 3.10.2
Pulsar: pulsar-client==3.2.0

Minimal reproduce step

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'

Activity

  1. Vincouux commented on Dec 11, 2023

    @Vincouux
    Author

    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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions