Beispiel #1
0
def main() -> str:
    # compilable
    data_xy = '{"type":"skin"}'
    data: Dict[str, Any] = json_deserialize(data_xy)
    type_ = cast(str, data['type'])

    # not compilable
    if type_ == "skin":
        data_xy = '{"type":"body"}'
        data: Dict[str, Any] = json_deserialize(data_xy)
        type_ = cast(str, data['type'])  # compile error on this line

    return type_
Beispiel #2
0
def loadStream(stream_id: int) -> Dict[str, Any]:
    """
    Load and deserialize a stream object from storage

    Args:
        stream_id (int): Stream ID

    Returns:
        Dict[str, Any]: Deserialized stream object
    """
    stream_key = b'streams/' + stream_id.to_bytes()
    s = get(b'streams/' + stream_id.to_bytes())
    assert len(s) > 0, 'no such stream exists'
    stream: Dict[str, Any] = json_deserialize(s)
    assert stream, 'stream deserialization failure'
    return stream
def main(json: bytes) -> Any:
    return json_deserialize(json)
Beispiel #4
0
def main(value: Any) -> Any:
    serialized = json.json_serialize(value)
    return json.json_deserialize(serialized)
Beispiel #5
0
def main(json: str) -> Any:
    return json_deserialize(json)