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
"arrayobject.length" jsonpath for the method selecttoken returned null instead of numerical value.
Expected behavior
It should return the array count.
Actual behavior
Returned null.
Steps to reproduce
// Your calls to Newtonsoft.Json herestringjsonExpressionText="$.attachment.length";JTokentoken= jsonObject.SelectToken(jsonExpressionText);Here, attachment is an array and the expression returns null.
The text was updated successfully, but these errors were encountered:
Rahna-S
changed the title
.length jsonpath for an array is supported selecttoken method
.length jsonpath for an array for the selectToken method returned null instead of count
Dec 1, 2023
Rahna-S
changed the title
.length jsonpath for an array for the selectToken method returned null instead of count
array.length jsonpath for the selectToken method returned null instead of count
Dec 1, 2023
I am only a user of Newtonsoft.Json and not otherwise associated with the project or its author/maintainer. That said, i would strongly suggest you ponder a possible migration from Newtonsoft.Json to System.Text.Json if JsonPath support is important to you. While JsonPath support in System.Text.Json itself is lacking as of now, there is the (in my opinion) excellent JsonPath.Net library (doc, github), which not only is substantially better than Newtonsoft.Json's JsonPath support (striving to support the current JsonPath specification), but it also is actively maintained. Plus, there is a handy JsonPath.Net-based online evaluator for quickly trying out and messing about with JsonPath expressions (https://json-everything.net/json-path/). However, JsonPath.Net relies on STJ and can't be used on top of Newtonsoft.Json.
If you don't want or cannot migrate to STJ, then i guess you unfortunately will be stuck with Newtonsoft.Json's quirky and outdated JsonPath implementation. Support for the length function (and other functions in JsonPath) has been asked for years ago (see this open ticket, for example: #1318), and in my frank opinion i would see it as a small miracle if Newtonsoft.Json were to receive noteworthy feature updates anymore. (Personally, i consider Newtonsoft.Json a largely feature-frozen legacy library, with System.Text.Json being the go-to for Json processing in .NET these days.)
"arrayobject.length" jsonpath for the method selecttoken returned null instead of numerical value.
Expected behavior
It should return the array count.
Actual behavior
Returned null.
Steps to reproduce
The text was updated successfully, but these errors were encountered: