Skip to content

Commit

Permalink
[change] 读取luban.conf及json数据源支持额外的comma及注释
Browse files Browse the repository at this point in the history
  • Loading branch information
pirunxi committed Mar 22, 2024
1 parent d2e8317 commit 5aeb05b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Luban.Core/GlobalConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public LubanConfig Load(string fileName)
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip,
};
var globalConf = JsonSerializer.Deserialize<LubanConf>(File.ReadAllText(fileName, Encoding.UTF8), options);

Expand Down
6 changes: 5 additions & 1 deletion src/Luban.DataLoader.Builtin/Json/JsonDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ public class JsonDataSource : DataLoaderBase
public override void Load(string rawUrl, string sheetOrFieldName, Stream stream)
{
RawUrl = rawUrl;
this._data = JsonDocument.Parse(stream).RootElement;
this._data = JsonDocument.Parse(stream, new JsonDocumentOptions()
{
AllowTrailingCommas = true,
CommentHandling = JsonCommentHandling.Skip,
}).RootElement;

if (!string.IsNullOrEmpty(sheetOrFieldName))
{
Expand Down

0 comments on commit 5aeb05b

Please sign in to comment.