Skip to content

Commit a1dcf0c

Browse files
committed
Add JsonPath feature
1 parent b613e51 commit a1dcf0c

24 files changed

+161
-52
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ Following works are done to make Json.NET support Unity3D.
3434
- Remove code related with System.ComponentModel.
3535
- Remove System.Data and EntityKey support.
3636
- Remove XML support.
37-
- Remove JPath class to reduce size of DLL.
3837
- Remove DiagnosticsTraceWriter support.
3938
- Workaround for differences between Microsoft.NET & Unity3D-Mono.NET
4039

4140
For Unity.Lite version, additional works are done to make more lite.
4241

43-
- Remove JsonLinq (JToken, ...)
42+
- Remove JsonLinq, JPath (JToken, ...)
4443
- Remove Bson
4544

4645
## Unit Test
@@ -54,8 +53,8 @@ Test Result:
5453

5554
| Profile |:white_check_mark: Passed | :x: Failed | :white_circle: Ignored |
5655
| :------------- | -----------------------: | ---------: | ---------------------: |
57-
| Microsoft.NET | 1448 | 0 | 1 |
58-
| Unity3D-Mono | 1435 | 13 | 1 |
56+
| Microsoft.NET | 1573 | 0 | 1 |
57+
| Unity3D-Mono | 1560 | 13 | 1 |
5958

6059
Detailed Description is [here](./docs/UnitTest.md) to tell you what failed and why.
6160

src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
<Compile Include="Linq\JObjectTests.cs" />
6969
<Compile Include="Linq\JPropertyTests.cs" />
7070
<Compile Include="Linq\JRawTests.cs" />
71+
<Compile Include="Linq\JsonPath\JPathExecuteTests.cs" />
72+
<Compile Include="Linq\JsonPath\JPathParseTests.cs" />
73+
<Compile Include="Linq\JsonPath\QueryExpressionTests.cs" />
7174
<Compile Include="Linq\JTokenEqualityComparerTests.cs" />
7275
<Compile Include="Linq\JTokenReaderTest.cs" />
7376
<Compile Include="Linq\JTokenTests.cs" />

src/Newtonsoft.Json/Linq/JToken.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
using System;
2929
using System.Collections.Generic;
30-
#if !UNITY3D
30+
#if !NO_JSONPATH
3131
using Newtonsoft.Json.Linq.JsonPath;
3232
#endif
3333
#if !(NET35 || NET20 || PORTABLE40)
@@ -2292,7 +2292,7 @@ int IJsonLineInfo.LinePosition
22922292
}
22932293
}
22942294

2295-
#if !UNITY3D
2295+
#if !NO_JSONPATH
22962296
/// <summary>
22972297
/// Selects a <see cref="JToken"/> using a JPath expression. Selects the token that matches the object path.
22982298
/// </summary>

src/Newtonsoft.Json/Linq/JsonPath/ArrayIndexFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
using System.Collections.Generic;
24
using System.Globalization;
35
using Newtonsoft.Json.Utilities;
@@ -41,4 +43,6 @@ public override IEnumerable<JToken> ExecuteFilter(IEnumerable<JToken> current, b
4143
}
4244
}
4345
}
44-
}
46+
}
47+
48+
#endif

src/Newtonsoft.Json/Linq/JsonPath/ArrayMultipleIndexFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
using System.Collections.Generic;
24

35
namespace Newtonsoft.Json.Linq.JsonPath
@@ -22,4 +24,6 @@ public override IEnumerable<JToken> ExecuteFilter(IEnumerable<JToken> current, b
2224
}
2325
}
2426
}
25-
}
27+
}
28+
29+
#endif

src/Newtonsoft.Json/Linq/JsonPath/ArraySliceFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
using System;
24
using System.Collections.Generic;
35
using System.Globalization;
@@ -85,4 +87,6 @@ private bool IsValid(int index, int stopIndex, bool positiveStep)
8587
return (index > stopIndex);
8688
}
8789
}
88-
}
90+
}
91+
92+
#endif

src/Newtonsoft.Json/Linq/JsonPath/FieldFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
using System.Collections.Generic;
24
using System.Globalization;
35
using Newtonsoft.Json.Utilities;
@@ -46,4 +48,6 @@ public override IEnumerable<JToken> ExecuteFilter(IEnumerable<JToken> current, b
4648
}
4749
}
4850
}
49-
}
51+
}
52+
53+
#endif

src/Newtonsoft.Json/Linq/JsonPath/FieldMultipleFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
using System.Collections.Generic;
24
using System.Globalization;
35
#if NET20
@@ -45,4 +47,6 @@ public override IEnumerable<JToken> ExecuteFilter(IEnumerable<JToken> current, b
4547
}
4648
}
4749
}
48-
}
50+
}
51+
52+
#endif

src/Newtonsoft.Json/Linq/JsonPath/JPath.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
#region License
24
// Copyright (c) 2007 James Newton-King
35
//
@@ -769,4 +771,6 @@ internal static IEnumerable<JToken> Evaluate(List<PathFilter> filters, JToken t,
769771
return current;
770772
}
771773
}
772-
}
774+
}
775+
776+
#endif

src/Newtonsoft.Json/Linq/JsonPath/PathFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if !NO_JSONPATH
2+
13
using System.Collections.Generic;
24
using System.Globalization;
35
using Newtonsoft.Json.Utilities;
@@ -52,4 +54,6 @@ protected static JToken GetTokenIndex(JToken t, bool errorWhenNoMatch, int index
5254
}
5355
}
5456
}
55-
}
57+
}
58+
59+
#endif

0 commit comments

Comments
 (0)