Get specific values form json file

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

@Mathkar_kunal

check above thread

here values in array splitting with comma.
will it get values one by one in array?

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

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())

image

Regards

one of many options which can also be adapted
grafik

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

  1. Deserialize JSON - Output as JObj
  2. 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 :slight_smile:
Cheers!!

@Mathkar_kunal

Jsonout("defects").ToString

image

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