Need some help in obtaining the values out of a Json String, below is the string
{
"Output": [
{
"Desc": "**This is a Test Change Request No action is required** HHC Remediation",
"Display": {
"display_value": "ft010",
"link": "https://test/api/now/table/ci/f706f150dbeb09d7c9619a3"
},
"start_date": "2022-10-27 02:08:37",
"description": "**This is a Test Change Request No action is required** \r\nLogin banner will be changed:\r\n\r\nftwlx001\r\nftd002\r\nftwlxhb4\r\n\r\nftw010\r\n",
"state": "Planning",
"end_date": "2022-10-31 02:08:43"
}
]
}
I need the below outputs
Desc, display_value, link,start_date, end_date, state, description
Hi @supermanPunch It is working thanks, can you please explain a bit why you used (0) and this seemed to be JArray to me is it?. Also in case of blank values we will get blank in response?
@Dhruvi_Arumugam , The Data Output / Input Provided is a Json Object. The Output is a property in it which is a JArray, In this JArray, we only have a Single JObject, Hence the first item access is done by (0).
Yes, The result should be an Empty value, if the values in the Json for the Properties are also blank.
{
"Output": [
{
"Desc": "Crew Hiring Forecast processing for August has stalled",
"Display": "",
"start_date": "",
"description": "Crew Hiring Forecast processing for August has stalled at File4",
"end_date": ""
}
]
}
The display attribute comes empty in case of blank values then if I am using
jobj("Output")(0)("display_value").ToString
It is failing due to attributes missing. Can you please guide handling this scenario?
Apologies for the Late response as I was quite busy with other tasks of mine.
I was not able to find a more direct approach of handling the Nested Json values existence. Hence, I Shifted to a method where we can validate that specific nested json keys after performing a conversion to a JObject for that key value (“Display”) and store it in a Dictionary for later access.
Maybe there is a better approach on this, but you could give a try on the below workflow. The workflow also assumes that we have the list of keys already known and only the nested keys to check would be “display_value” and “link”. Json_ConvertToDictionary.xaml (12.1 KB)
After the First Deserialization we could check if there are any JArrays present, we could encapsulate the remaining steps within an If Activity where the condition would be as below :
That would be the Second Deserialize Json Activity. You would need to add steps as explained in the previous post before this Second Deserialize Json Activity.