decode_attrs

Contents

decode_attrs#

eoio.serialisation.attrs.decode_attrs(obj: T, *, sniff: bool = True, inplace: bool = False) → T[source]#

Restore attributes previously encoded for serialisation.

Where an eoio:attr_encoding marker is present its codecs are used, giving an exact round trip. Attributes with no marker entry are sniffed instead, recognising only JSON objects/arrays and ISO-8601 datetimes.

Parameters:
  • obj – Dataset, DataArray or DataTree whose attributes should be decoded.

  • sniff – Whether to attempt best-effort decoding of unmarked attributes. Set False to decode only what the marker describes.

  • inplace – Whether to modify obj rather than a copy.

Returns:

The object with decoded attributes, and the marker attribute removed.