public string ReComposeJson_Identify(string json_in) { json_get_minutiae json_from_WebAPI; //de-serialize json string from web api. using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json_in))) { DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(json_get_minutiae)); json_from_WebAPI = (json_get_minutiae)deseralizer.ReadObject(ms);// //反序列化ReadObject } //put together as new serialize json string as server need json_srv_indetify json_to_srv = new json_srv_indetify(); string ret_str; using (var ms = new MemoryStream()) { DataContractJsonSerializer seralizer = new DataContractJsonSerializer(typeof(json_srv_indetify)); //assign one json to another json json_to_srv.encMinutiae = json_from_WebAPI.data.encMinutiae; json_to_srv.eSkey = json_from_WebAPI.data.eSkey; json_to_srv.iv = json_from_WebAPI.data.iv; //write to stream seralizer.WriteObject(ms, json_to_srv); ms.Position = 0; StreamReader sr = new StreamReader(ms, Encoding.UTF8); ret_str = sr.ReadToEnd(); sr.Close(); } return(ret_str); }
public string BuildJson_Identify(string encMinutiae, string eSkey, string iv) { //put together as new serialize json string as server need json_srv_indetify json_to_srv = new json_srv_indetify(); string ret_str; using (var ms = new MemoryStream()) { DataContractJsonSerializer seralizer = new DataContractJsonSerializer(typeof(json_srv_indetify)); //assign one json to another json json_to_srv.encMinutiae = encMinutiae; json_to_srv.eSkey = eSkey; json_to_srv.iv = iv; //write to stream seralizer.WriteObject(ms, json_to_srv); ms.Position = 0; StreamReader sr = new StreamReader(ms, Encoding.UTF8); ret_str = sr.ReadToEnd(); sr.Close(); } return(ret_str); }