How to get data from this

Hi i am hinting an api and below is the reponse i am getting

{

"encrypted": "none",

"partner": "salesforce",

}

],

"status": “version”: “1.1”,`

`"form

}

how can get batch id from this

1 Like

Hi

check this out Deserialize JSON in UiPath | UiPath in 5 minutes | Ep:3

1 Like

Hi @manoj_verma1,

First you need to use a Deserialize Json activity(https://docs.uipath.com/activities/docs/deserialize-json), where the input is your json as string.

There you will define an output variable, let’s say jsonObject.

Then, you can access the batchId property like this:

jsonObject("batchId").toString

If this solves your problem, kindly mark this post as solution.

Thanks!

Here you can check a similar post, if you need: How to quickly get the value from a json

1 Like

Hi

Let’s take like you have a string variable named JsonString

Now use a Deserialise Json activity

and pass the above string and choose the type as Newtonsoft.Json.Linq.JObject

Then get the output as out_Json

Now use a assign activity like this to get the final output you want

Stroutput = out_Json.SelectToken(“batchId”).ToString

Hope this would help you resolve this
Cheers @manoj_verma1

2 Likes

Hey @manoj_verma1 !! Lets go to the solution!

  • First you need to make sure this string matches the correct JSON standards. Because it is a JSON.

  • After that directly store that string from where you’re reading so you don’t have problems with the quotes. As an example, I’ll read directly from a .txt and store it in the String variable “str_json”.

  • Let’s then use the “Deserialize JSON” activity, this activity converts a String, which is in String format, to a JSON of type JObject. That’s because as you want to extract the values ​​of these fields, this way we can do it directly and without problems.

  • We store this Output in a variable of type JObject “jobj_result”, note its type.

  • Finally, we can access any field of interest only with this command <variable_jobject>("<argument_name>"), see the example:


Hope it helps!!

1 Like

getting error object reference not set to instance followed same way

1 Like

Hi

May I know at which activity you are getting this error

@manoj_verma1

1 Like

getting error object reference not set to instance followed same way

1 Like

Hi @manoj_verma1,

Have you tried this?

yourVariableName("batches")(0)("batchId").toString

2 Likes

whn i am using assign activity

1 Like

Where are you using that assign activity? Send us screenshot of your workflow if possible. Thanks!

2 Likes

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