using System; using ln.type.rpc; namespace ln.json.mapping { public class JSONRPCCallMapping : JSONMapping { public JSONRPCCallMapping() :base(typeof(RPCCall)) { } public override object FromJson(JSONMapper mapper, JSONValue jsonValue) { JSONObject json = jsonValue as JSONObject; RPCCall call = new RPCCall(); if (json.ContainsKey("id")) { call.Identifier = json["id"].ToNative(); } else { call.Identifier = Guid.NewGuid(); } if (json.ContainsKey("module")) call.ModuleName = JSONMapper.DefaultMapper.FromJson(json["module"]); if (json.ContainsKey("method")) call.MethodName = JSONMapper.DefaultMapper.FromJson(json["method"]); if (json.ContainsKey("parameters")) call.Parameters = JSONMapper.DefaultMapper.FromJson(json["parameters"]); else call.Parameters = new object[0]; return call; } } }