Hello,
i need to split below json and need to get values of defects
check below json
{
“testExecutionKey”: “P000110-15004”,
“tests”: [
{
“status”: “PASS-PARTIALLY”,
“testKey”: “P000110-6436”,
“start”: “2023-11-22T09:43:48+01:00”,
“executedBy”: “abc”,
“defects”: [
“P000110-15008”,
“P000110-15008.1”
],
“evidences”: ,
“steps”: [
{
“status”: “PASS”,
“defects”: ,
“evidences”:
},
{
“status”: “EXECUTING”,
“defects”: [
“attachment1/P000110-14943”,
“attachment2/P000110-14944”
],
“evidences”:
}
],
“assignee”: “abc”,
“testEnvironments”: ,
“iterations”: ,
“comment”: “null”
}
]
}
i need values under defects which are
“P000110-15008”,
“P000110-15008.1”
and values under second defect which is in steps
“attachment1/P000110-14943”,
“attachment2/P000110-14944”
let me now how can i achieve this
one json file contains multiple testKey’s which is under “testExecutionKey” but one json contains only one testExecutionKey
above is for one test key
here values in array splitting with comma.
will it get values one by one in array?
supriya117
(Supriya Allada)
February 1, 2024, 10:24am
4
Hi @Mathkar_kunal
Deserialize JSON: JSONString → jsonObject
defectsArray = jsonObject("tests")(0)("defects").ToString
stepsArray = jsonObject("tests")(0)("steps").ToArray
secondDefectsArray = stepsArray(1)("defects").ToString
Hi @Mathkar_kunal
jsonObject("tests")(0)("defects").ToString
jsonObject("tests")(0)("steps")(1)("defects").ToString
Hope it helps!!
1 Like
vrdabberu
(Varunraj Dabberu)
February 1, 2024, 10:26am
6
Hi @Mathkar_kunal
Try the below syntaxes:
defectsValues= String.Join(vbCrLf,JObject("tests")(0)("defects").ToObject(Of JArray).Select(Function(x) x.ToString()).ToArray())
secondDefectsValues= String.Join(vbcrlf,JObject("tests")(0)("steps")(1)("defects").ToObject(Of JArray).Select(Function(x) x.ToString()).ToArray())
Regards
ppr
(Peter Preuss)
February 1, 2024, 10:43am
7
one of many options which can also be adapted
1 Like
thanks can u tell how to extract defect from ollowing
{
“status”: “EXECUTING”,
“defects”: [
“P000110-14943”,
“P000110-149434”
],
“evidences”:
}
need below values
“P000110-14943”,
“P000110-149434”
Hi @Mathkar_kunal
Deserialize JSON - Output as JObj
Use Assign Activity with Variable ArrDefects - String(Of Array)
And use below expression
ArrDefects = If(JObj.SelectToken(“tests[0].defects”) IsNot Nothing, JObj.SelectToken(“tests[0].defects”).ToObject(Of String()), Nothing)
Hope it will helps you
Cheers!!
@Mathkar_kunal
Jsonout("defects").ToString
system
(system)
Closed
February 4, 2024, 10:54am
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.