Json For Each

Hello!

I downloaded your project to check your solution but when I opened it uipath shows that error.

image

How for each activity is defined ?

This is what I have in for each activity @Lucky0906

Could you please tell me how to give key to any json array.

below is my extracted education data from linkedin which is in the form of json object :
[{“Degree Name”:“Certificate”,“Degree in Subject”:“Blockchain Strategy”,“University Name”:“Saïd Business School, University of Oxford”},{“Degree Name”:“Master of Science (MS)”,“Degree in Subject”:“IT - Business Intelligence \u0026 Data Management”,“University Name”:“Boston University”},{“Degree Name”:“BE”,“Degree in Subject”:“Computer Science”,“University Name”:“Manonmaniam Sundaranar University”}]

@Sunita_Hembram,

Can you explain a bit, I was confused with your question.

Actually, within the JSON object, you will have the key to get the JSON array.

[{“Degree Name”:“Certificate”,“Degree in Subject”:“Blockchain Strategy”,“University Name”:“Saïd Business School, University of Oxford”},{“Degree Name”:“Master of Science (MS)”,“Degree in Subject”:“IT - Business Intelligence \u0026 Data Management”,“University Name”:“Boston University”},{“Degree Name”:“BE”,“Degree in Subject”:“Computer Science”,“University Name”:“Manonmaniam Sundaranar University”}]

above is the json array of three objects right… i want to give a parent key to that json array…is it possible ? if yes, then how.

Got it @Sunita_Hembram, You have to use Deserialize JSON array to get the values inside the array.

Else , if you want to pass it as a JSON object, you just need to add some tags like

“{ KeyNameYouWantToProvide : ArrayYouHave }”

Make sure the key name is between the single quotes or if you want to pass it to the external applications (other than UiPath activities), replace single quotes with double quotes

actually i want result like:

{
“Education”: [ Json data what i shared with you]
}

Yeah, I hope you got it as a string when you scrape the data from linkedin, so append the text like

"{ ‘Education’ : " + String you got after scraping + " } "

This will give you the JSON object

which activity i have to use

Assign will work, you can change the existing variable or you can create new

and what about following steps:

  • JsonConvert.SerializeObject(dtt) : to have the the datatable in Json format

  • JArray.Parse : to have that json in array containing all json (all the rows of that datatable )

  • var.Add(“documents”, arr) : to add main key "document on top of that array

  • then again JsonConvert.SerializeObject(out argumentof invoke ) to have main json

explain me if u know these things.

"{ ‘Education’ : " + String you got after scraping + " } " is not working , i want double quotation for Education then it will become perfect json object with key as Education

I discussed the same above like if you want the perfect JSON, you need to use double quotes :slight_smile: