encode

function of dascore.utils.identity source

encode(
    obj: Any ,
)-> ‘Any’

Return the canonical JSON-safe tree standing for an object.

Every value is kept, containers are framed so that no two of them read alike, and a value which cannot be spelled faithfully raises ParameterError rather than being named by its type.

Examples

import numpy as np
from dascore.utils.identity import encode
encode(np.timedelta64(1, "s"))
{'$timedelta64': 1000000000}