From 5aeb05b0b75fd0a8e014b271392b6ba491d01bd5 Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 22 Mar 2024 14:19:25 +0800 Subject: [PATCH] =?UTF-8?q?[change]=20=E8=AF=BB=E5=8F=96luban.conf?= =?UTF-8?q?=E5=8F=8Ajson=E6=95=B0=E6=8D=AE=E6=BA=90=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=A2=9D=E5=A4=96=E7=9A=84comma=E5=8F=8A=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban.Core/GlobalConfigLoader.cs | 2 ++ src/Luban.DataLoader.Builtin/Json/JsonDataSource.cs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Luban.Core/GlobalConfigLoader.cs b/src/Luban.Core/GlobalConfigLoader.cs index b746057d..4018d4c1 100644 --- a/src/Luban.Core/GlobalConfigLoader.cs +++ b/src/Luban.Core/GlobalConfigLoader.cs @@ -62,6 +62,8 @@ public LubanConfig Load(string fileName) var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, + AllowTrailingCommas = true, + ReadCommentHandling = JsonCommentHandling.Skip, }; var globalConf = JsonSerializer.Deserialize(File.ReadAllText(fileName, Encoding.UTF8), options); diff --git a/src/Luban.DataLoader.Builtin/Json/JsonDataSource.cs b/src/Luban.DataLoader.Builtin/Json/JsonDataSource.cs index 00324362..e5b0a92a 100644 --- a/src/Luban.DataLoader.Builtin/Json/JsonDataSource.cs +++ b/src/Luban.DataLoader.Builtin/Json/JsonDataSource.cs @@ -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)) {