Deserialize json array not working!


#1

Please find my json file below, when I try to deserialize it to an array I receive the error :
Deserialize json array : Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path ‘’, line 1, position 1.

Please help, very simple but not working
response-data-export.json (9.4 KB)
Main.xaml (14.2 KB)

{
“items” : [ {
“job_ID” : 15,
“appName” : “Sample_Dynamic”,
“dbName” : “Basic”,
“jobType” : “MaxL Script”,
“jobfileName” : “sample_dynamic.msh”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523484221000,
“endTime” : 1523484227000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/15”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/15”,
“method” : “POST”
} ]
}, {
“job_ID” : 14,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample3.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523365311000,
“endTime” : 1523365325000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/14”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/14”,
“method” : “POST”
} ]
}, {
“job_ID” : 13,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523364991000,
“endTime” : 1523365002000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/13”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/13”,
“method” : “POST”
} ]
}, {
“job_ID” : 12,
“appName” : “Sample_Dynamic”,
“dbName” : “Basic”,
“jobType” : “Import Excel”,
“jobfileName” : “Sample_Basic_Dynamic.xlsx”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523364354000,
“endTime” : 1523364378000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/12”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/12”,
“method” : “POST”
} ]
}, {
“job_ID” : 11,
“appName” : “Sample_Dynamic”,
“dbName” : “Basic”,
“jobType” : “Calc Execution”,
“jobfileName” : “CalcAll”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523357857000,
“endTime” : 1523357859000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/11”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/11”,
“method” : “POST”
} ]
}, {
“job_ID” : 10,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample3.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523302533000,
“endTime” : 1523302545000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/10”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/10”,
“method” : “POST”
} ]
}, {
“job_ID” : 9,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample2.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523292284000,
“endTime” : 1523292298000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/9”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/9”,
“method” : “POST”
} ]
}, {
“job_ID” : 8,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523292208000,
“endTime” : 1523292221000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/8”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/8”,
“method” : “POST”
} ]
}, {
“job_ID” : 7,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523290470000,
“endTime” : 1523290484000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/7”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/7”,
“method” : “POST”
} ]
}, {
“job_ID” : 6,
“appName” : “Sample_Dynamic”,
“dbName” : null,
“jobType” : “LCM Export”,
“jobfileName” : “Sample.zip”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523287968000,
“endTime” : 1523287982000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/6”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/6”,
“method” : “POST”
} ]
}, {
“job_ID” : 5,
“appName” : “Sample_Dynamic”,
“dbName” : “Basic”,
“jobType” : “Import Excel”,
“jobfileName” : “Sample_Basic.xlsx”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523277255000,
“endTime” : 1523277279000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/5”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/5”,
“method” : “POST”
} ]
}, {
“job_ID” : 4,
“appName” : “BIZHYP”,
“dbName” : “bizhyp1”,
“jobType” : “Import Excel”,
“jobfileName” : “bizhyp.xlsx”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523275747000,
“endTime” : 1523275765000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/4”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/4”,
“method” : “POST”
} ]
}, {
“job_ID” : 3,
“appName” : “BIZHYP”,
“dbName” : “bizhyp1”,
“jobType” : “Import Excel”,
“jobfileName” : “bizhyp.xlsx”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523234585000,
“endTime” : 1523234599000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/3”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/3”,
“method” : “POST”
} ]
}, {
“job_ID” : 2,
“appName” : “BIZHYP”,
“dbName” : “bizhyp1”,
“jobType” : “Import Excel”,
“jobfileName” : “bizhyp.xlsx”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523234430000,
“endTime” : 1523234445000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/2”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/2”,
“method” : “POST”
} ]
}, {
“job_ID” : 1,
“appName” : “BIZHYP”,
“dbName” : “bizhyp1”,
“jobType” : “Import Excel”,
“jobfileName” : “bizhyp.xlsx”,
“userName” : "ivossos@gmail.com",
“startTime” : 1523233782000,
“endTime” : 1523233801000,
“statusCode” : 200,
“statusMessage” : “Completed”,
“links” : [ {
“rel” : “canonical”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/1”,
“method” : “GET”
}, {
“rel” : “post”,
“href” : “https://ess-bizhyp.uscom-central-1.oraclecloud.com:443/essbase/rest/v1/jobs/1”,
“method” : “POST”
} ]
} ],
“totalResults” : 15,
“limit” : 20,
“offset” : 0,
“hasMore” : false
}


#2

The root of json is not in array format. You have to use Deserialize json activity to achieve this.
Check right side box in the below image. The root “object {5}” is not an array but “item [15]” is.


#3

Thanks Madhavi! How can I resolve this in uipath?


#4

@yannisv UiPath has a Deserializa Json activity use that to get Json object of your string and then use deserializedData.item to iterate through the item array.


#5

Thanks again Madhavi for replying! Can you please attach the xaml file? Also coudnt find the deserializedData.item activity


#6

@yannisv Here you go… JsonDeserialize.xaml (10.2 KB)


#7

Thank you again! However I need the tabular format i.e. “job_ID” “appName” etc. line by line


#8

that you can get inside for loop by accessing the element as
line(“job_ID”)
line(“appName”)
etc


Extract specific values from nested JSOn output
#9

Tried to do it like this line(“job_ID”).ToString on the write line inside the loop, I got the following error:
05/03/2018 07:18:25 Write line : Object reference not set to an instance of an object.


#10

@yannisv Working as expected. No error…


Extract specific values from nested JSOn output
Unable to deserialize json