pydrepr/drepr/models/drepr.py
def _serde_engine_value(self, value: Any):
        """Serialize a python value to a json representation of the Value struct in the Rust engine"""
        if value is None:
            return {"t": "Null"}
        elif isinstance(value, bool):
            return {"t": "Bool", "c": value}
        elif isinstance(value, int):
            return {"t": "I64", "c": value}
        elif isinstance(value, float):
            return {"t": "F64", "c": value}
        elif isinstance(value, str):
            return {"t": "Str", "c": value}
        elif isinstance(value, list):
            return {"t": "Array", "c": [self._serde_engine_value(v) for v in value]}
        elif isinstance(value, (dict, OrderedDict)):
            return {"t": "Object", "c": {
                k: self._serde_engine_value(v)
                for k, v in value.items()
            }}
        else:
            raise InputError(f"Cannot serialize the value of type: {type(value)} to JSON")
Serialize a python value to a json representation of the Value struct in the Rust engine
Serialize a python value to a json representation of the Value struct in the Rust engine
Serialize a python value to a json representation of the Value struct in the Rust engine
def _serde_engine_value(self, value: Any):
        if value is None:
            return {"t": "Null"}
        elif isinstance(value, bool):
            return {"t": "Bool", "c": value}
        elif isinstance(value, int):
            return {"t": "I64", "c": value}
        elif isinstance(value, float):
            return {"t": "F64", "c": value}
        elif isinstance(value, str):
            return {"t": "Str", "c": value}
        elif isinstance(value, list):
            return {"t": "Array", "c": [self._serde_engine_value(v) for v in value]}
        elif isinstance(value, (dict, OrderedDict)):
            return {"t": "Object", "c": {
                k: self._serde_engine_value(v)
                for k, v in value.items()
            }}
        else:
            raise InputError(f"Cannot serialize the value of type: {type(value)} to JSON")
def _serde_engine_value ( self , value : Any ) : if value is None : return { "t" : "Null" } elif isinstance ( value , bool ) : return { "t" : "Bool" , "c" : value } elif isinstance ( value , int ) : return { "t" : "I64" , "c" : value } elif isinstance ( value , float ) : return { "t" : "F64" , "c" : value } elif isinstance ( value , str ) : return { "t" : "Str" , "c" : value } elif isinstance ( value , list ) : return { "t" : "Array" , "c" : [ self . _serde_engine_value ( v ) for v in value ] } elif isinstance ( value , ( dict , OrderedDict ) ) : return { "t" : "Object" , "c" : { k : self . _serde_engine_value ( v ) for k , v in value . items ( ) } } else : raise InputError ( f"Cannot serialize the value of type: {type(value)} to JSON" )
Serialize a python value to a json representation of the Value struct in the Rust engine
Serialize a python value to a json representation of the Value struct in the Rust engine
"""Serialize a python value to a json representation of the Value struct in the Rust engine"""
self
value
Any