private void TestResult() { string json = @"{'rpc_tag': '__RPC_RESULT__', 'handle': 'testfun', 'uid': 666, 'result': ['some string', {'rpc_tag': '__RPC_VAL_NDARRAY__', 'dtype': 'int64', 'shape': [3], 'data': 'BgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAA'} ] }"; PyUniResult call = PyUniType.JsonConstructor <PyUniResult>(json) as PyUniResult; string newjson = call.PackJSON(); print(newjson); }
private void TestCall() { string json = @"{'rpc_tag': '__RPC_CALL__', 'handle': 'testfun', 'uid': 666, 'args': ['lul', 'wut'], 'kwargs': {'some string': {'rpc_tag': '__RPC_VAL_NDARRAY__', 'dtype': 'int64', 'shape': [3], 'data': 'BgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAA'} } }"; PyUniCall call = PyUniType.JsonConstructor <PyUniCall>(json) as PyUniCall; string newjson = call.PackJSON(); print(newjson); }
private void TestError() { string json = @"{'rpc_tag': '__RPC_ERROR__', 'handle': 'testfun', 'uid': 666, 'exception': 'ValueError', 'descr' : 'whoops' }"; var result = PyUniType.JsonConstructor <PyUniResult>(json); try { var res = result as PyUniResult; Debug.Log(res.result[0]); } catch (Exception) { var err = result as PyUniError; Debug.LogError($"{err.exception}: {err.descr}"); } }