-Fixed JSON Path not equal null with non-primative values

This commit is contained in:
James Newton-King
2016-03-21 21:00:44 +13:00
parent 310769995a
commit 031222d4f4
2 changed files with 92 additions and 39 deletions
@@ -902,5 +902,43 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
Assert.AreEqual("Headlight Fluid", firstProductNames[1]);
Assert.AreEqual(149.95m, totalPrice);
}
[Test]
public void NotEqualsNullAndNonPrimativeValues()
{
string json = @"[
{
""name"": ""string"",
""value"": ""aString""
},
{
""name"": ""number"",
""value"": 123
},
{
""name"": ""array"",
""value"": [
1,
2,
3,
4
]
},
{
""name"": ""object"",
""value"": {
""1"": 1
}
}
]";
JArray a = JArray.Parse(json);
List<JToken> result = a.SelectTokens("$.[?(@.value!=null)]").ToList();
Assert.AreEqual(4, result.Count);
result = a.SelectTokens("$.[?(@.value)]").ToList();
Assert.AreEqual(4, result.Count);
}
}
}