Exemplo n.º 1
0
        public static string CreateJsonResponse(int id, Object result)
        {
            var resp = new JsonRpcResponse();
            resp.JsonRpc = "2.0";
            resp.Id = id;
            resp.Error = null;
            resp.Result = result;

            var jsonSettings = new JsonSerializerSettings();
            jsonSettings.NullValueHandling = NullValueHandling.Ignore;

            return JsonConvert.SerializeObject(resp, Formatting.Indented, jsonSettings);
        }
Exemplo n.º 2
0
        public static JsonRpcResponse CreateJsonErrorResponse(int id, int code, string message, string data)
        {
            var error = new JsonRpcError();
            error.Code = code;
            error.Data = data;
            error.Message = message;

            var resp = new JsonRpcResponse();
            resp.JsonRpc = "2.0";
            resp.Id = id;
            resp.Error = error;
            resp.Result = null;

            return resp;
        }