How to print jsonobject variyable in to convert datatable?

how to print jsonobject variyable in to convert datatable???

{
“result”: [
{
“headrow”: {
“rowno”: {
“hide”: “false”
},
“axrowtype”: {
“hide”: “true”,
“width”: “80”,
“dec”: “0”,
“type”: “c”
},
“axp__font”: {
“axp__font”: “axp__fontdetails”,
“hide”: “true”,
“width”: “80”,
“dec”: “0”,
“type”: “c”
},
“new_empno”: {
“new_empno”: “new_empno”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “1”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“first_name”: {
“first_name”: “first_name”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “2”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
}

  "row": [
    {
      "rowno": "1",
      "new_empno": "100001",
      "first_name": "Samyiyya"       
     
    },
    {
      "rowno": "2",
      "new_empno": "100002",
      "first_name": "Abdulsalam"
     
    },
    {
      "rowno": "3",
      "new_empno": "100005",
      "first_name": "Chitra"
               
    },

how convert datatable … share sequance

@domsmgtmeet22,

Follow this thread.

Thanks,
Ashok :slight_smile:

i not understand provide correct workflow

Hi @domsmgtmeet22

=> Use Build Data Table activity and specify the columns
image
Output → dt

=> Read the JSON text file and store the output in a vairable say jsonString.

=> Use Deserialize JSON activity pass JSON String as jsonString and create a variable to store the Output say jsonObject.

=> Run a For Each loop and give the below syntax:

For Each currentJToken in jsonObject("result")("row")
   Add Data Row activity
      Array Row = {currentJToken("rowno").ToString(), currentJToken("new_empno").ToString(), currentJToken("first_name").ToString()}
      DataTable = dt
End For Each

=> Use Write Range Workbook to write dt to excel.

FLOW:

XAML:
Sequence2.xaml (11.6 KB)

OUTPUT:
image

Regards

is not file it was api output

so kindly share any imformation

Hi @domsmgtmeet22

Read text file activity is not required pass the output variable of API response into Deserialize JSON activity and the rest of the process is same.

Regards

@domsmgtmeet22
the Quick dirty approach:

use the returned JSON String and parse it within a JObject
grafik
out: myJObject

Assign Activity:
dtData = myJObject(“result”)(0)(“row”).ToObject(Of DataTable)

grafik

OR
construct the Datatable dynamic from the row header definitions
loop over row Property value (a JArray)
Add the the different property values to the DataTable

{
“result”: [
{
“headrow”: {
“rowno”: {
“hide”: “false”
},
“axrowtype”: {
“hide”: “true”,
“width”: “80”,
“dec”: “0”,
“type”: “c”
},
“axp__font”: {
“axp__font”: “axp__fontdetails”,
“hide”: “true”,
“width”: “80”,
“dec”: “0”,
“type”: “c”
},
“new_empno”: {
“new_empno”: “new_empno”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “1”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“first_name”: {
“first_name”: “first_name”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “2”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“branch_shrt”: {
“branch_shrt”: “branch_shrt”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “3”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“department_name”: {
“department_name”: “department_name”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “4”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“division_name”: {
“division_name”: “division_name”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “5”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“cost_center”: {
“cost_center”: “cost_center”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “6”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“bcc”: {
“bcc”: “bcc”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “7”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“createdon”: {
“createdon”: “createdon”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “8”,
“runningtotal”: “False”,
“type”: “d”,
“hide”: “false”
},
“modifiedon”: {
“modifiedon”: “modifiedon”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “9”,
“runningtotal”: “False”,
“type”: “d”,
“hide”: “false”
},
“last_name”: {
“last_name”: “last_name”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “10”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“email”: {
“email”: “email”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “11”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“mobile_no”: {
“mobile_no”: “mobile_no”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “12”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“doj”: {
“doj”: “doj”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “13”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“reporting_to”: {
“reporting_to”: “reporting_to”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “14”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“designation_name”: {
“designation_name”: “designation_name”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “15”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“nurse_regno1”: {
“nurse_regno1”: “nurse_regno1”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “16”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“nurse_valid_date”: {
“nurse_valid_date”: “nurse_valid_date”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “17”,
“runningtotal”: “False”,
“type”: “d”,
“hide”: “false”
},
“subdivision”: {
“subdivision”: “subdivision”,
“width”: “80”,
“dec”: “0”,
“align”: “Left”,
“ordno”: “18”,
“runningtotal”: “False”,
“type”: “c”,
“hide”: “false”
},
“reccount”: “10119”,
“totalrows”: “10119”,
“datarows”: “10119”
},
“row”: [
{
“rowno”: “1”,
“new_empno”: “100001”,
“first_name”: “Samyiyya”,
“branch_shrt”: “KCN”,
“department_name”: “Facility Services”,
“division_name”: “Engineering”,
“cost_center”: “Unit”,
“bcc”: “KCN-Unit”,
“createdon”: “01/11/1992”,
“modifiedon”: “15/12/2023 5:12:42 PM”,
“last_name”: “R”,
“email”: “”,
“mobile_no”: “9486143147”,
“doj”: “01/11/1992”,
“reporting_to”: “111297 Dhananjayan J”,
“designation_name”: “Senior Gas plant Operator”,
“nurse_regno1”: “”,
“nurse_valid_date”: “”,
“subdivision”: “Facility Engineering”
},
{
“rowno”: “2”,
“new_empno”: “100002”,
“first_name”: “Abdulsalam”,
“branch_shrt”: “KCN”,
“department_name”: “Facility Services”,
“division_name”: “Facility Services”,
“cost_center”: “Unit”,
“bcc”: “KCN-Unit”,
“createdon”: “01/04/1995”,
“modifiedon”: “26/06/2021 10:24:52 AM”,
“last_name”: “M”,
“email”: “”,
“mobile_no”: “9976919400”,
“doj”: “01/04/1995”,
“reporting_to”: “100443 Lalith Kumar G”,
“designation_name”: “House Keeping Supervisor”,
“nurse_regno1”: “”,
“nurse_valid_date”: “”,
“subdivision”: “House Keeping”
},
{
“rowno”: “3”,
“new_empno”: “100005”,
“first_name”: “Chitra”,
“branch_shrt”: “KCN”,
“department_name”: “Clinical Nursing”,
“division_name”: “OPD”,
“cost_center”: “Unit”,
“bcc”: “KCN-Unit”,
“createdon”: “11/05/1999”,
“modifiedon”: “12/10/2021 5:49:47 PM”,
“last_name”: “S”,
“email”: “”,
“mobile_no”: “7708623092”,
“doj”: “11/05/1999”,
“reporting_to”: “109275 Stella P”,
“designation_name”: “Senior Assistant”,
“nurse_regno1”: “”,
“nurse_valid_date”: “”,
“subdivision”: “General OP”
}

how to convert this api response in datatable

Similar as answered in your other thread:

1 Like

Hey @domsmgtmeet22
You can try this solution:

BlankProcess131.zip (9.5 KB)



The out put was not showing…


how to print its output

@domsmgtmeet22
What do you mean by “output not showing”? The output is stored in the dt variable in my solution.
I have attached the project for you, so please take a look :slight_smile:

I wrote blog post about it here: Converting json to DataTable in UiPath – Beyond RPA – Blog about different RPA-related topics
This is basically what @ppr already provided.