Not able to extract values from Json string

Hi All

Not able to extract values from json string. Below is the string. This response result iam getting form API Call

“{
“message”: “ponse":{"bulkQuoteID":{"id":"52858","displayId":"BQ-52858"},"customerBatchName":"ip vpn integrated- test","status":"2","statusDetails":"Batch of 1, processed 0, errored 0 ","productName":"PC550"}}”,”

I need to extract"“52858” value from Json string
I tried with deseralization json but not able to extract.

Can some one help on this

@Thunga_Hima

Please try this

After deserializing say the output is jobj

Then use

Jobj("Message")("ponse")("displayId").ToString.Split({"-"},StringnSplitOptions.None)(1)

Also the json you gave looks incomplete or wrong…if there is some difference please correct and accordingly use it…the idea is for each key that is before colon you can include a new ("Key") till the last is reached

Looks like the syntax is wrong at ponse in teh given json

Cheers

Hi,

Iam getting below error on Deserializing json

Deserialize JSON: Unexpected character encountered while parsing value: p. Path ‘’, line 0, position 0.

@Thunga_Hima

Did you change type argument to jobject

And can you please post the exact response youa re getting as mentioned earlier the posted onw looks like a mal formed json

Cheers

Hi,

Below is the response iam getting from API call.

ponse":{“bulkQuoteID”:{“id”:“52861”,“displayId”:“BQ-52861”},“customerBatchName”:“ip vpn integrated- test”,“status”:“2”,“statusDetails”:"Batch of 1, processed 0, errored 0 ",“productName”:“PC550”}}

Below is the properities of Dserilazation json activity.

@Thunga_Hima

Still this looks incomplete

i guess you have {response:

Etc

And in the type argument what did you select

Cheers

Type of Argument using is Newtonsoft.Json.Linq.Jobject

@Thunga_Hima

Can you please write the response to a file and attach or give the correct response to give you the correct code

Because the json provided till now are invalid

Cheers

please download the valid file from http request

Hi @Thunga_Hima

To extract the value “52858” from the given JSON string, you can use the following steps:

  1. Parse the JSON string: First, you need to parse the JSON string into a JSON object or dictionary that you can work with. In UiPath, you can use the Deserialize JSON activity to achieve this.
  2. Access the desired value: Once the JSON string is parsed, you can access the specific value you need by navigating through the JSON structure. In this case, you want to extract the value associated with the key “id” inside “bulkQuoteID”.

Thanks!!

Thanks For the help

1 Like

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