Silverlight json 通信

asp.net 端

using System.Web.Script.Serialization;
//List转json字符串
{
IList<OBJ> list=New List<OBJ>();
...
JavaScriptSerializer jsonStr = new JavaScriptSerializer();
return jsonStr.Serialize(list);
}

  SilverLight 端

{
WebClient client = new WebClient();
Uri uri = new Uri(App.Current.Host.Source,"http://xxxxx//xx.ashx");
client.DownloadStringCompleted += GetJSONCompleted;
client.DownloadStringAsync(uri);
}

private void GetJSONCompleted(object sender, DownloadStringCompletedEventArgs e)
{
JsonArray jArray = (JsonArray)JsonArray.Parse(e.Result.ToString());
//1. foreach (string str in jArray.ToList()){}
//2. foreach (JsonObject jObj in jArray){string str=jObj["
原文地址:https://www.cnblogs.com/glj161/p/3245909.html