XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.Test/Program.cs
+4
-8
Modified
XFEExtension.NetCore/XFETransform/JsonConverter/JsonNodeConverter.cs
+13
-1
XFEstudio/XFEExtension
修复部分Json解析问题
5d8b03b
代码差异
2 个文件
+17
-9
@@ -1,16 +1,12 @@
1
using System.Formats.Asn1;
2
using XFEExtension.NetCore.FileExtension;
3
using XFEExtension.NetCore.StringExtension;
4
using XFEExtension.NetCore.StringExtension.Json;
5
using XFEExtension.NetCore.Test;
1
using XFEExtension.NetCore.FileExtension;
6
2
using XFEExtension.NetCore.XFETransform.JsonConverter;
7
3
8
4
internal class Program
9
5
{
10
6
private static void Main(string[] args)
11
7
{
12
//QueryableJsonNode jsonNode = @"C:\Users\XFEstudio\Desktop\测试\Json数组解析失败.txt".ReadOut()!;
13
var testClass = new TestClass("123", "sda", 12);
14
testClass.ToJson().CW();
8
QueryableJsonNode jsonNode = @"C:\Users\XFEstudio\Desktop\测试\Json数组解析失败.txt".ReadOut()!;
9
//var testClass = new TestClass("123", "sda", 12);
10
//testClass.ToJson().CW();
15
11
}
16
12
}
@@ -9,7 +9,7 @@ public class JsonNodeConverter(string jsonString)
9
9
private int currentLayer = -1;
10
10
private string currentPropertyName = "";
11
11
private string currentPropertyValue = "";
12
private readonly List<short> currentPosition = [0];
12
private readonly List<short> currentPosition = new List<short> { 0 };
13
13
private string jsonString = jsonString;
14
14
/// <summary>
15
15
/// 原始Json字符串
@@ -265,10 +265,22 @@ public class JsonNodeConverter(string jsonString)
265
265
for (int i = 0; i < indexes.Count - 1; i++)
266
266
{
267
267
short index = indexes[i];
268
// Guard against invalid indexes to avoid ArgumentOutOfRangeException.
269
if (index < 0 || index >= currentJsonComplexPropertyNode.DescendingNodes.Count)
270
{
271
// If the requested index is out of range, stop descending and return the current node.
272
return currentJsonComplexPropertyNode;
273
}
274
268
275
if (currentJsonComplexPropertyNode.DescendingNodes[index] is JsonComplexPropertyNode complexPropertyNode)
269
276
{
270
277
currentJsonComplexPropertyNode = complexPropertyNode;
271
278
}
279
else
280
{
281
// If the node at the index is not a complex node, stop descending.
282
return currentJsonComplexPropertyNode;
283
}
272
284
}
273
285
return currentJsonComplexPropertyNode;
274
286
}