yanghuan/proton

关于导出 Json 文件格式的问题

Closed this issue · 1 comments

你的工具精简但是很强大,首先谢谢的工具,减轻了些负担。
可以修改下 Json 的导出格式么?这样可以快速的支持 Unity 的 Json 工具。
我以 mount.xlsx 这个文件举例。
使用此文件导出的 Json,Unity 需要两个类,如下:
`[System.Serializable]
public class MountList
{
public Mount[] DataList;
}

[System.Serializable]
public class Mount
{
public int Id;
public string Name;

public Mount(int id, string name)
{
    Id = id;
    Name = name;
}

} 对应的 Json 文件{
"DataList": [
{
"Id": 1001,
"Name": "战车"
},
{
"Id": 1001,
"Name": "马"
},
{
"Id": 1001,
"Name": "飞毯"
}
]
}而工具生成的文件如下:[
{
"Id": 10001,
"Name": "战车"
},
{
"Id": 10002,
"Name": "马"
},
{
"Id": 10003,
"Name": "飞毯"
}
]`
无法直接通过 Unity 的 Json 工具类进行解析。
建议在生成的 Json 的数组时加上数组名,类似 Json 工具类生成的 json 文件。
为了能支持 Unity Json 工具类手动修改工作量也不大,但 Unity Json 工具类生成的文件蛮清晰的。
再者发现 Json 解析非常耗时,可以进一步支持转化到 ScriptableObject 对象,测试发现解析速度最快的,但不支持子线程解析。