How to select specific data from a string

Hi every one i have a json response like below i need only “display_name” how can i get that i tried using select token but it was not working can any one help me how to do that using regex or in any other way

[
{
“transform_map”: “CAP Interaction WS”,
“table”: “interaction”,
“display_name”: “number”,
“display_value”: “imnryh3567”,
“record_link”: “”,
“status”: “inserted”,
“sys_id”: “d40dc6f01b92e854868dddb6bb4bcb9b”
}
]

Hi @bpt.teja1996

Try to deserialize the json string and get the display name value directly by dictionary format

Or try using regex pattern too

check as below

Regards
Nived N

Happy Automation

2 Likes

@bpt.teja1996
as it is a json you can use deserialize JSON (Array) Activity (reference UiPath.WebAPI.Activities within the dependency manager)

After parsing it into a JObject acces a property by: YourJSONObjectVar(“PropertyName”) e.g. YourJSONObjectVar(“display_value”)

1 Like

@NIVED_NAMBIAR can we show me how to use regex in UIpath I have that entire string in variable number how to apply regex to that now

Hi @bpt.teja1996
You can try this way

Lets say u store the entire string in number variable

Then use assign activity as below

display_name=System.Text.RegularExpressions.Regex.Match(number, “(?<=“display_name”:).*”).Value

1 Like

@NIVED_NAMBIAR I don’t want that " before and after the numbera

Hi @bpt.teja1996

Did u got result using the regex pattern using above assign activvity?

@NIVED_NAMBIAR sorry I was late night hear so I have not tried will try in in the morning but as in the above pic I don’t need those " before and after the number also

Hi @bpt.teja1996

After extraction u can try like this

display_name.Replace(""","").Replace(""","")

@NIVED_NAMBIAR i am getting error for this exprexxion System.Text.RegularExpressions.Regex.Match(number, “(?<=“display_name”:).*”).Value

Check this below link, @bpt.teja1996

Hope this may help you :slight_smile:

@ppr @NIVED_NAMBIAR @NIVED_NAMBIAR i am not able to get the required out out can any one help me how to get the display number using this

@bpt.teja1996
grafik
grafik

Find starter Help here:
ParseJSONArray_UseFirstJObject.xaml (5.6 KB)

@ppr in that it was completly in one line but for me it in line by line line
“display value”: “IMddd”
“display_name”:“number”

@ppr thank you very much it was working fine

@bpt.teja1996

Perfect. Just do your final testing and close the topic by marking the solving post as solution if there are no further open questions. So others can benefit from this. Thanks