相关疑难解决方法(0)

重复序列化和反序列化会创建重复项

大家好我的json serealization问题.我在Unity下使用Json.NET包:我正在搜索一个数据库,可以在我的应用程序上编辑,并通过wwwForm和一个php文件存储在我的服务器上.我没有问题来创建它并将其推到网上.问题是,当我加载它时,数据库最后有一个新条目.数据库类是这样的:

public class Database   {
    public List<Army> armies { get; set;}

    public Database() {
        armies = new List<Army>();
        armies.Add (new Army());
    }
}

public class Army
{
    public string faction { get; set;}
    public List<Unit> army { get; set;}

    public Army()
    {
        faction = "RED";
        army = new List<Unit>();
        army.Add (new Unit());
    }
}

public class Unit
{
    public string name { get; set;}
    public float fissionTimer { get; set;}
    public float HP { get; set;}
    public int shield …
Run Code Online (Sandbox Code Playgroud)

c# serialization json json.net unity-game-engine

5
推荐指数
1
解决办法
2407
查看次数

标签 统计

c# ×1

json ×1

json.net ×1

serialization ×1

unity-game-engine ×1