Skip to content

Inconsistent to_json() return type #1766

@deepankarm

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions