Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To expose Linq.JsonPath.JPath to enable query-centric use cases #2985

Open
xhoms opened this issue Oct 9, 2024 · 1 comment
Open

To expose Linq.JsonPath.JPath to enable query-centric use cases #2985

xhoms opened this issue Oct 9, 2024 · 1 comment

Comments

@xhoms
Copy link

xhoms commented Oct 9, 2024

It would be great to have the JPath class and a slightly modified version of its Evaluate(JToken obj, JsonSelectSettings? settings) method publicly accessible to be able to use pre-parsed versions of JSON Paths in query intensive applications like in this mocked code that attempts to check if a JObject instance matches any of multiple rules in a large collection.

List<string> veryLargeCollectionOfJPathRules = [
     "$..childN.propA",
     "$..childN.childM.propA",
     ];

var compiledRules = veryLargeCollectionOfJPathRules.ConvertAll(path => new JPath(path)); // to have JPath exposed
var hasMatch = compiledRules.Any(rule => rule.Evaluate(objectUnderTest).Any()); // to have Evaluate() exposed
@JJLovesLife
Copy link

Vote for this. If we query the same JSONPath on tons of JTokens, parsing the same JSONPath every time is a huge performance burden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants