static public string StructRequestToString(StructRequest request) { JObject obj = new JObject(); obj.Add("uid", request.uid); obj.Add("request_url", request.request_url); Dictionary <string, string> dic = request.parameter; if (dic != null) { obj["parameter"] = JObject.FromObject(dic).ToString(); } return(obj.ToString()); }
static public StructRequest StringToStructRequest(string msg) { JObject obj = JObject.Parse(msg); StructRequest reqeust = new StructRequest(); reqeust.uid = obj.Value <string>("uid"); reqeust.request_url = obj.Value <string>("request_url"); if (obj.ContainsKey("parameter")) { string parameter = obj.Value <string>("parameter"); Dictionary <string, string> praram = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameter); reqeust.parameter = praram; } return(reqeust); }