Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Inconsistent to_json() return type #1766

Description

@deepankarm

Initial Checks

  • I have read and followed the docs and still think this is a bug

Description

to_json() returns a str for models inherited from BaseDoc, whereas it is bytes for DocList

Example Code

from docarray import BaseDoc, DocList


class MyModel(BaseDoc):
    text: str
        
print(type(MyModel(text="abc").to_json())) # <class 'str'>
print(type(DocList[MyModel]([MyModel(text="abc")]).to_json())) # <class 'bytes'>

Docarray Version

0.37.1

Affected Components

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions