悉野小楼

导航

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);

 下载 创建更新列表Json

posted on 2023-10-09 15:46  悉野  阅读(20)  评论(0编辑  收藏  举报