Extract fields value from Deserialize JSON output

What is best way to extract relevant information from Deseralize Result (Output of Deserialize JSON activity) —> First Name, Last Name and other field details?

image

DeseralizeResult(“fields”)(“description”) output is coming as below.

User Details:

  • First Name : xxx
  • Last Name : xxxx
  • Preferred Name : null
  • Gender : Male
  • EmployeeStatus : Permanent
  • Division : xxxxxxxxxxx Portfolio
  • Department : xxxxxxxxxxxx
  • Position : xxx
  • Product : null
  • Location : xxxxxxxxxx
  • State : xxxxxxxxx
  • Start Date : 16/08/2021
  • End Date : -

@Cristian_Negulescu : Any inputs or suggestions for this query.

Hi @Sonalk ,

Try
DeseralizeResult.SelectToken(“FirstName”).ToString

Better provide example of your JSON

Cheers

@ermanoj3101 : Getting this message

image

@J0ska : Please find the deserialize output (output of Deserialize JSON as JSON Object).

Objective is to extract values from First Name, Last Name, Gender, Location etc. So i am looking for robust solution for this problem statement.

output deserialize.txt (458 Bytes)

I see. In that case the best way will be to use regex to parse the content of DeseralizeResult(“fields”)(“description”)

Cheers

Hi @Sonalk ,

You can try regex then

System.Text.RegularExpressions.Regex.Match(strTest,“(?<=Position \W )(\S+.*)”).value

Note: I have shown here for one value you can pass fields in loop to get each value.

@Sonalk

Working with select Token allows us to specifiy the extractor definition on string base.
So we can define a extraction config map like (Dummy, not your case specifics)
FieldName, SToken
DIVISION, $.Division

Later we can dynamicly

  • set up eg. datatable with the corresponding column structure
  • looping over the config map rows - extracting the values and add it to the datatable

This approach gives us flexibility and we can avoid redundand implementations parts

Have a look on selecttoken here:

Let us know your further questions

@ppr : I am actually having three description values as an output after API response. so below screenshot may give wrong value ( my objective is to extract values from third description value : First Name, Last Name etc.) → Find the attachment for your reference.

“description”: “This issue is being xxx.”,
“description”: “”,
“description”: “User Details:\n\n* First Name : xxx\n* Last Name : xxxx\n* Preferred Name : null”

image
JSON Output.txt (10.5 KB)

Thanks for providing Regex input. I am fine to export values in loop.
Please find the attachment. There are three description fields in JSON output. I need to extract third description and then using regex to extract values. Any best method to extract third description field value as string?

“description”: “This issue is being xxx.”,
“description”: “”,
“description”: “User Details:\n\n* First Name : xxx\n* Last Name : xxxx\n* Preferred Name : null”

JSON Output.txt (10.5 KB)

SelectToken approach can also handle this (see here, same linked topic)

$.identifications.[0].identificationStatus.status - here [0] was used for taking the first.

In case of further help is needed, I can have a closer look on it.

Are you looking for this?
"description": "User Details:\n\n* First Name : xxx\n* Last Name : xxxx\n* Preferred Name : null\n* Gender : Male\n* ",

@ppr - yes i am interested to fetch and then using regex to extract First Name, Last Name, Gender values and store to variables.

“description”: "User Details:\n\n* First Name : xxx\n* Last Name : xxxx\n* Preferred Name : null\n* Gender : Male\n* ",

only 1 description is child of fields and on this you are interested. We can simplify
grafik

And esxtract with regex:
grafik

So extraction config table mentioned from above can be adopted for supporting the regex extraction if it is wished

grafik

1 Like

Thanks @ppr @ermanoj3101 for your inputs

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