c# json操作
使用JavaScriptSerializer
需要在引用中添加System.Web.Extensions
using System.Web.Script.Serialization; class UpdateInfo { public string packageUrl; public string remoteManifestUrl; public string remoteVersionUrl; public string version; public string engineVersion; public Dictionary<string, AssertInfo> assets; } UpdateInfo updateInfo = new UpdateInfo(); updateInfo.packageUrl = this.txtPackageUrl.Text; updateInfo.remoteManifestUrl = this.txtRemoteManifestUrl.Text; updateInfo.remoteVersionUrl = this.txtRemoteVersionUrl.Text; updateInfo.version = this.txtVersion.Text; updateInfo.engineVersion = this.txtEngineVersion.Text; updateInfo.assets = m_assets; //创建一个JavaScriptSerializer对象 JavaScriptSerializer serializer = new JavaScriptSerializer(); //将用户列表序列化成JSON string serializedResult = serializer.Serialize(updateInfo); //UpdateInfo deserializeResult = serializer.Deserialize<UpdateInfo>(serializedResult); File.WriteAllText(m_dir + "\\project.manifest", serializedResult);