HTTP Request: Extract multiple data after deserialize

I am having trouble extracting all the “snippet” after I have deserialized json, how can I do this?

@ashton.lalchan

May I know what you want to extract?

Cheers

@ashton.lalchan

You need to check, but this should get you to the right enumerable.

(“webPages”)(“value”)(0)(“deepLinks”)

Then loop through the enumerable and extract by (“snippet”). Something like this should work.

Hi @Anil_G, I am trying to extract all the snippets in the Webpage.

You have deserialized the JSON - myJObject

Assign Activity:
arrSnippets | String Array =
myJObject.SelectTokens("..snippet").Select(Function (x) x.Value(Of String)).ToArray

For further Assistance share the JSON as Text File with us


this is my workflow @ppr . I need this for additional business information. via “snippets”. where would I put this line of code you recommended?

Becuase I need to be able to also pass that varibale that contains the snippets to a GenAI activity

have a look here as it allows you to do instant prototyping
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

as mentioned above
JsonObject.SelectTokens("..snippet").Select(Function (x) x.Value(Of String)).ToArray

Kindly note:

where does this line of code go? @ppr
JsonObject.SelectTokens(“…snippet”).Select(Function (x) x.Value(Of String)).ToArray

As mentioned:

use an assign Activity

for prototypings it can be used directly within the immediate panel

@ashton.lalchan To solve this you need to follow below steps

Step 1: You need to typecast the JSON string to JSON Object
Step 2: You also can write the custom activity to get the data in the object, I will give you C# code for convert the data in object
or You can write the custom VB script for the same.
Step 3: once you get the data into the object you can get it from it.

Hi @ppr Basically i have an api using HTTP request and it gives a bing search shown in the screenshot. and I want to be able to extract any and all snippets. how could this be done?

below should do it, did you try e.g. within the immediate panel?

These are the steps that I have taken:

  1. HTTP Request: this gets a bing search of whatever i want to find
  2. In this search ^ the screenshot I have attached to thread is what is outputted by API
  3. To extract the snippet, i first deserialize Json
  4. then I deserialize Json Array by JsonObject(“webPages”)(“value”).ToString
  5. for the object reference for this^^ i create a for each loop to loop through
  6. in this loop I assign each item as item(“snippet”).ToString.

based on this, can you provide input on how I can extract any and all snippet based on the output . @ppr

Kindly note that we also mentioned a few times that for further assistance the JSON As text file should be shared with us.

  • HTTP Request: this gets a bing search of whatever i want to find
  • In this search ^ the screenshot I have attached to thread is what is outputted by API
  • To extract the snippet, i first deserialize Json - output: myJObject

Then just use:

yea but my question is where does this go in my workflow. after deserialize Array?. also I dont fully understand what inputs are needed. can you explain please.
myJObject.SelectTokens(“…snippet”).Select(Function (x) x.Value(Of String)).ToArray

i would greatly appreciate it. thanks

maybe you re-reread all given answers

was not mentioned

Also we would prefer to get your JSON as text file for further assistance. We can faster help and it would also avoid the ping-pongs

hi @ppr here is the txt file for the api output.
API response.json (9.8 KB)

@ppr hi, essentially I want to concat all snippets within website → values together and save it to a variable to use later on, how can this be done?

where you also can use any other seperation string e.g Environment.NewLine for a line break