<JSON Value Extracting> How to extract worklogs value "uipath" from below mentioned json?

JSON Doc.txt (741 Bytes)

{
“transactionId”: “”,
“invokingUser”: “”,
“timestamp”: “”,
“data”: [
{
“created_by”: “”,
“created_date”: “”,
“status”: “ABC”,
“attachments”: [
{
“created_by”: “”,
“created_date”: “”
}
],
“action_items”: ,
“worklogs”: [
{
“created_by”: “UiPath”,
“created_date”: “”
},
{
“created_by”: “”,
“created_date”: “”
}
]
}
],
“version”: null,
“duration”: 50
}

I used >> myJObject(“data”)(0)(“status”).Value(Of String) to retrieve status value from this json.
Any help is appreciated,

@anjasing

Try this:

myJObject  = JObject.Parse(YourJsonString)

uiPathCreatedBy = myJObject("data")(0)("worklogs").Where(Function(w) w("created_by").ToString() = "UiPath").FirstOrDefault()?("created_by").ToString()
1 Like

Hi @anjasing

Could you provide the output, then only we are able to know which want to extract.

1 Like

HI @mkankatala ,

I want to get data → worklogs ->> created by → which is UiPath

UiPath is the output

Hey @anjasing
try to use this method:

worklogs  = myJObject("data")(0)("worklogs")
uipathWorklogs = worklogs.Where(Function(w) w("created_by").ToString() = "UiPath")

For Each worklog In uipathWorklogs
    worklog("created_date").ToString
1 Like

Can you please tell the variable type of worklogs, UiPath worklogs

Okay @anjasing

Follow the below step by step process,
→ Take Read text file activity to read the text file and store in a String datatype variable. Output → Input_Str.
→ Use the Deserialize JSON activity
Input → Input_Str (string datataype)
Output → JsonObject
→ Use for each activity and give the below one

JsonObject("data")(0)("worklogs")

→ Inside for each insert the assign activity to store the value.

- Assign -> Output = currentItem("created_by")

→ After assign activity insert break activity to break the loop.

Check the below image for better understanding,

Output -

Hope it helps!!

1 Like

@anjasing
you can use IEnumerable(Of JObject)
uipathWorklogs = worklogs.Cast(Of JObject)().Where(Function(w) w("created_by").ToString() = "UiPath")

1 Like

Thank you soooo much for such a detailed explanation. It worked. :slight_smile:

It’s my pleasure… @anjasing

Happy Automation!!

1 Like

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