JSON Selecttokens filter

Hello

I am looking for a JSON filter expression to grab all tokens that “starts with” something.
The expression below does not work:

jobj_JsonObject.SelectTokens("..[?(@.identifier starts with 'Beskrivelse')]").Count

Best regards
Soren

Hi @SorenB

Can you try this

jobj_JsonObject.SelectTokens("..[?(@.identifier =~ /^Beskrivelse/)]").Count

Regards,

Hello @lrtetala

Thank you that seems to work :grinning: :+1:

Are you able to explain to me the meaning of the different characters in the expression, so that I can better understand what is going on?

=~
/^Beskrivelse/

Perhaps also:

..[?(@

What does the individual characters represent/mean in the expression?

Regards
Soren

@SorenB

By using regex
=~ /^Beskrivelse/ Uses a regex pattern to match values that start with "Beskrivelse". The ^ ensures the match starts at the beginning of the string.

Regars,

1 Like

Thank you.
I have marked your post as the solution.

1 Like

lets have shared some more docu and tool resources

Docu:
Initial JSONPath Definition
https://goessner.net/articles/JsonPath/
Newtonsoft Samples:

Future Work / ongoing

Tools
JSONPath Online Evaluator
:warning: the JSONPath Support can differ from the Implementation of the Newtonsoft Package. The Newtonsoft Package Implementation is the relevant one, for the UiPath modellings

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.