How to get value from jtoken

Hi there, could you someone please help me get value from Jtoken? My api call to QueueProcessingRecords/UiPathODataSvc.RetrieveQueuesProcessingStatus gives me this:
{
@odata.context”: “https://cloud.uipath.com”,
@odata.count”: 1,
“value”: [
{
“ItemsToProcess”: 0,
“ItemsInProgress”: 0,
“QueueDefinitionId”: 525,
“QueueDefinitionName”: “awardsQueue”,
“QueueDefinitionDescription”: “Awards to roll”,
“QueueDefinitionAcceptAutomaticallyRetry”: true,
“QueueDefinitionMaxNumberOfRetries”: 1,
“QueueDefinitionEnforceUniqueReference”: true,
“ProcessingMeanTime”: 15.288629,
“SuccessfulTransactionsNo”: 333,
“ApplicationExceptionsNo”: 2,
“BusinessExceptionsNo”: 219,
“SuccessfulTransactionsProcessingTime”: 17.7,
“ApplicationExceptionsProcessingTime”: 94.35,
“BusinessExceptionsProcessingTime”: 10.9,
“TotalNumberOfTransactions”: 554,
“LastProcessed”: “2021-06-25T03:43:39.4766667Z”,
“ReleaseName”: null,
“ReleaseId”: null,
“IsProcessInCurrentFolder”: null,
“SpecificDataJsonSchemaExists”: true,
“OutputDataJsonSchemaExists”: true,
“AnalyticsDataJsonSchemaExists”: true,
“ProcessScheduleId”: null,
“QueueFoldersCount”: 1,
“Id”: 525
}
]
}

I deserialized the reponse to Linq.JObject. Then I assigned jobjQueueSummary(“value”).ToString to jtokenQ (jtoken type variable). Which gives me this:

[[
{
“ItemsToProcess”: 0,
“ItemsInProgress”: 0,
“QueueDefinitionId”: 525,
“QueueDefinitionName”: “awardsQueue”,
“QueueDefinitionDescription”: “Awards to roll”,
“QueueDefinitionAcceptAutomaticallyRetry”: true,
“QueueDefinitionMaxNumberOfRetries”: 1,
“QueueDefinitionEnforceUniqueReference”: true,
“ProcessingMeanTime”: 15.288629,
“SuccessfulTransactionsNo”: 333,
“ApplicationExceptionsNo”: 2,
“BusinessExceptionsNo”: 219,
“SuccessfulTransactionsProcessingTime”: 17.7,
“ApplicationExceptionsProcessingTime”: 94.35,
“BusinessExceptionsProcessingTime”: 10.9,
“TotalNumberOfTransactions”: 554,
“LastProcessed”: “2021-06-25T03:43:39.4766667Z”,
“ReleaseName”: null,
“ReleaseId”: null,
“IsProcessInCurrentFolder”: null,
“SpecificDataJsonSchemaExists”: true,
“OutputDataJsonSchemaExists”: true,
“AnalyticsDataJsonSchemaExists”: true,
“ProcessScheduleId”: null,
“QueueFoldersCount”: 1,
“Id”: 525
}
]]

Then I’m trying to get the value of QueueDefinitionName from the jtokenQ:

tokenQ.SelectToken(“QueueDefinitionName”).ToString gives me:
Cannot evaluate ‘tokenQ.SelectToken(“QueueDefinitionName”).ToString’ at current context.

Tried this:
tokenQ(“QueueDefinitionName”).ToString gives me:
Cannot evaluate ‘tokenQ(“QueueDefinitionName”).ToString’ at current context.

What am I missing here? I noticed double square brackets from tokenQ, is that array within an array?

I appreciate the help. Thanks.

give a try on below for accessing the first Id for test/RnD purpose
jobjQueueSummary(“value”).Values(Of JObject)(0)(“Id”).toString

Also Have a looke here:

Thank you for the quick response. I’ll give those a try.

Solved.

tokenQ.SelectToken("$.[0].QueueDefinitionName").ToString

Thanks

Perfect. Just do your final testing and may we ask you to close the topic by marking the solving post. So others can benefit from it. Thanks

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