c#json操作
引用中 增加 system.web.Extension; 和system.web.services ;
json 轉對象
private T scriptDeserialize<T>(string jsonstr)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<T>(jsonstr);
}
對象轉json
private string getJsonStr(JsonSendPlayback jsplaybcak)
{
JavaScriptSerializer js = new JavaScriptSerializer();
Dictionary<string, string> drow = new Dictionary<string, string>();
drow.Add("videoId", jsplaybcak.VideoId);
drow.Add("mobId", jsplaybcak.MobId);
drow.Add("nodeId", jsplaybcak.NodeId);
drow.Add("highPriority", jsplaybcak.HighPriority.ToString());
drow.Add("overwrite", jsplaybcak.Overwrite.ToString());
drow.Add("profile", jsplaybcak.Profile);
drow.Add("ProcessName", jsplaybcak.ProcessName);
drow.Add("device", jsplaybcak.Device);
return js.Serialize(drow);
}
c#json操作