docarray.document.mixins.porting module#
- class docarray.document.mixins.porting.PortingMixin[source]#
Bases:
object
- classmethod from_dict(obj, protocol='jsonschema', **kwargs)[source]#
Convert a dict object into a Document.
- Parameters:
obj (
Dict
) – a Python dict objectprotocol (
str
) – jsonschema or protobufkwargs – extra key-value args pass to pydantic and protobuf parser.
- Return type:
T
- Returns:
the parsed Document object
- classmethod from_json(obj, protocol='jsonschema', **kwargs)[source]#
Convert a JSON string into a Document.
- Parameters:
obj (
Union
[str
,bytes
,bytearray
]) – a valid JSON stringprotocol (
str
) – jsonschema or protobufkwargs – extra key-value args pass to pydantic and protobuf parser.
- Return type:
T
- Returns:
the parsed Document object
- to_dict(protocol='jsonschema', **kwargs)[source]#
Convert itself into a Python dict object.
- Parameters:
protocol (
str
) – jsonschema or protobufkwargs – extra key-value args pass to pydantic and protobuf dumper.
- Return type:
Dict
[str
,Any
]- Returns:
the dumped Document as a dict object
- classmethod from_bytes(data, protocol='pickle', compress=None)[source]#
Build Document object from binary bytes
- Parameters:
data (
bytes
) – binary bytesprotocol (
str
) – protocol to usecompress (
Optional
[str
]) – compress method to use
- Return type:
T
- Returns:
a Document object
- to_json(protocol='jsonschema', **kwargs)[source]#
Convert itself into a JSON string.
- Parameters:
protocol (
str
) – jsonschema or protobufkwargs – extra key-value args pass to pydantic and protobuf dumper.
- Return type:
str
- Returns:
the dumped JSON string