How to split json like [ ]

Hello,

hi have huge json like below

“completedCycles”: ,
“ongoingCycle”: {
“startTime”: {
“iso8601”: “2023-04-04T10:28:39+02:00”,
“jira”: “2023-04-04T10:28:39.376+02:00”,
“friendly”: “16 minutes ago”,
“epochMillis”: 1680596919376
},
“breachTime”: {
“iso8601”: “2023-04-04T14:28:39+02:00”,
“jira”: “2023-04-04T14:28:39.376+02:00”,
“friendly”: “In 3 hours”,
“epochMillis”: 1680611319376

i need to saperate friendly value which is “in 3 Hours” form json

how can i saperate that?
is completedCycles": this is an array?

PLEASE HELP ME ON SAME.

@Mathkar_kunal

What you mean split?

if you want to access that then use deserialize json and from output jobj("completedCycles") will give you the jarray which can be access further like this jobj("completedCycles")(0) - this gives first element of array

And yes that is a jarray

cheers

Hey @Mathkar_kunal ,
You can use deserialize json Activity to convert your input from string to Jobject
Let the output will be JsonObject

image

Then Put : JsonObject("friendly").ToString

I believe “completedCycles” is not an array

Regards,

it looks like this
image

@Mathkar_kunal ,
Yes Now we can say that its an Array.
But your "friendly " does not belong to that array that array is Null i believe.
Can you share that input file?

Regards,

full json is very big and i cant share because of security concerns.
Can you help me if that aray is closed then how can i extract that required value?

@Mathkar_kunal ,
Ok .Assuming that your input will be in a text file,
1.Use a Read Text File activity
2.Store the output in a string variable Lets say “JsonString”
3. Use “Deserialize Json” Activity to deserialize the json string to Jobject
4.Ouytput of the Deserialze Json activity will be “JsonObject”
5. Then you have to see whether your required output(Friendly) is inside the array or not
6.If its inside the array then you have to retrieve that item using
JsonObject("ArrayName")(0)("friendly").ToString
7. Or if it is not inside the array You can directly write JsonObject("friendly").ToString

Note : If the value “friendly” is repeated several times in the same array then you have to change the array index from 0 to 1 2 3 etc

Regards,

3 Likes

Read text
Deserialize JSON - ensure that TypeArgument is set to JObject -out: myJObject

Assign Activity
strFriendly =
myJObject("completedCycles")("breachtime")("friendly").Value(Of String)

1 Like

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