You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should return an empty enumerable, because the correct result of applying your JsonPath expression to your given json data example should be an empty result. (If you observe SelectTokens returning a null reference instead of an empty enumerable, post a complete self-contained compilable code example that reproduces this behavior. Preferably put it on dotnetfiddle https://dotnetfiddle.net/, so it is certain that it is self-contained.)
If v12.0.3 produces anything other than an empty result for your given json example and JsonPath expression, then the bug is in v12.0.3 (and, if true, then presumably fixed in 13.0.x). Applying your given JsonPath expression to your json example must give an empty result according to the JsonPath specification. Your JsonPath expression looks for children of WSAAccrualProfile which have some @name property. But no child of WSAAccrualProfile has a @name property (only WSAAccrualProfile itself has). Hence why the correct result for the given JsonPath expression must be empty here.
So basically, v13.0.x yielding an empty result is the correct result.
You need to fix your JsonPath expression. One possible JsonPath expression that would select what you want is:
It selects any object that has a WSAAccrualProfile child object with a @name property with a "-TIL" value and then selects the WSAAccrualProfile child from that object. (Note that i haven't tested this with Newtonsoft.Json. I am not using Newtonsoft.Json anymore. Its limited JsonPath support is based on the very old Goessner JsonPath spec from 2007, and i haven't verified if the JsonPath i suggested isn't using any features not yet available in that old JsonPath spec. I believe it should be fine but i am not sure, so YMMV... FYI: I verified the correctness of my JsonPath expression using the https://json-everything.net/json-path online JsonPath evaluator, which is based on System.Text.Json and the JsonPath.Net package.)
My complex JSONPath queries that worked with version 12 and below no longer work with version 13+
Source/destination JSON
{
"id": 21,
"name": "Accrual Profiles",
"uniqueKey": "WSAAccrualProfile",
"itemsRetrieveResponseDTOs": [],
"itemsRetrieveResponses": [
{
"itemDataInfo": {
"title": "-TIL",
"key": "-TIL",
"env": null,
"urlparams": "Name=-TIL"
},
"responseObjectNode": {
"@Status": "Success",
"@action": "RetrieveForUpdate",
"WSAAccrualProfile": {
"@name": "-TIL",
"AccrualProfilePolicies": {
"WSAAccrualProfilePolicy": [
{
"@AccrualPolicy": "-Time In Lieu",
"@display": true
},
{
"@AccrualPolicy": "-Time In Lieu 2",
"@display": true
}
]
},
"@PersistentID": "-TIL",
"AccrualProfileBalanceCascadeGroups": {
"WSAAccrualProfileBalanceCascadeGroup": {
"@BalanceCascadeGroup": "-TIL"
}
}
}
}
}
]
}
Expected behavior
I expect to get a IEnumberable from calling SelectTokens(path) with this path
$..['WSAAccrualProfile'][?(@['@name']=='-TIL')]
the above path works in v12.0.3
Actual behavior
null is returned from SelectTokens(path)
Steps to reproduce
The text was updated successfully, but these errors were encountered: