28 lines
942 B
C#
28 lines
942 B
C#
using System.IO;
|
||
using System.Text.Json;
|
||
|
||
namespace XWorld.PublishTool
|
||
{
|
||
// resolved-spec.json(Editor 侧 JsonUtility 产出,字段名小写)→ GameSpec。
|
||
// GameSpec 用 public 字段,故必须 IncludeFields;键名大小写不敏感。
|
||
public static class GameSpecJson
|
||
{
|
||
private static readonly JsonSerializerOptions Opts = new JsonSerializerOptions
|
||
{
|
||
IncludeFields = true,
|
||
PropertyNameCaseInsensitive = true,
|
||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||
AllowTrailingCommas = true,
|
||
};
|
||
|
||
public static GameSpec Parse(string json)
|
||
{
|
||
var s = JsonSerializer.Deserialize<GameSpec>(json, Opts);
|
||
if (s.Assets == null) s.Assets = new System.Collections.Generic.List<string>();
|
||
return s;
|
||
}
|
||
|
||
public static GameSpec ParseFile(string path) => Parse(File.ReadAllText(path));
|
||
}
|
||
}
|