-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Update JSONPathMatcher.cs to cover the string path selection to a child #993
Conversation
The .SelectToken method accept string path selection and JSONPath queries. The current code works only for the queries because the result is JObject. When the string path is selected the result is JValue and event with a valid result the code the code doesn't return valued result. https://www.newtonsoft.com/json/help/html/SelectToken.htm
Update JSONPathMatcher.cs to cover the string path selection to a child
@DayLightDancer |
Added the unit tests. I am not able to run the entire solution locally so the tests are created and run on separate solution and added in the existed file. |
@@ -123,7 +123,12 @@ private double IsMatch(JToken jToken) | |||
{ | |||
var array = ConvertJTokenToJArrayIfNeeded(jToken); | |||
|
|||
return MatchScores.ToScore(_patterns.Select(pattern => array.SelectToken(pattern.GetPattern())?.Any() == true).ToArray(), MatchOperator); | |||
// The SelectToken method can accept string path to a child token ( i.e. “Manufacturers[0].Products[0].Price”) in that cat it will return a JValue(some type) which not implement the IEnumerable interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the comment to this?
// The SelectToken method can accept a string path to a child token ( i.e. "Manufacturers[0].Products[0].Price"). In that case it will return a JValue (some type) which does not implement the IEnumerable interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only write this 1 line comment
Thanks. Can you take a look at the comments? |
I've addressed the comments |
HI, Please tell me if there is anything to do with that PR and when I can expect the new build? |
You set the comments to resolved, but did you also commit your latest changes? |
I think so. I've edited the files in place. I will appreciate any help complete that PR. |
it seems that the files are not changed, can you please double check? |
Replace it by a one line:
|
Can you check it, now? |
I will merge this one and update it myself. |
@@ -123,7 +123,12 @@ private double IsMatch(JToken jToken) | |||
{ | |||
var array = ConvertJTokenToJArrayIfNeeded(jToken); | |||
|
|||
return MatchScores.ToScore(_patterns.Select(pattern => array.SelectToken(pattern.GetPattern())?.Any() == true).ToArray(), MatchOperator); | |||
// The SelectToken method can accept string path to a child token ( i.e. “Manufacturers[0].Products[0].Price”) in that cat it will return a JValue(some type) which not implement the IEnumerable interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only write this 1 line comment
Thank you verry much. I really appreciate it. |
The .SelectToken method accept string path selection and JSONPath queries. The current code works only for the queries because the result is JObject. When the string path is selected the result is JValue and event with a valid result the code the code doesn't return valued result.
https://www.newtonsoft.com/json/help/html/SelectToken.htm