How to parse json with specified key value using SIL

MeterSphere Demo June 8, 2022

Below is the sample of the JSON. I want to get the id and workspaceId with the given value of jirakey using SIL. 

In this given JSON, how to get id and workspaceId with "jirakey=MD" ?

 

--------------------------------------------------

{
"success": true,
"message": null,
"data": [
{
"id": "AAAAAAAAAAAAAAA",
"workspaceId": "BBBBBBBBBBBBBBBB",
"name": "name01",
"description": null,
"jiraKey": "MD",
"platform": "Jira",
"workspaceName": "workspace1"
},
{
"id": "CCCCCCCCCCCCCCCCCC",
"workspaceId": "dddddddddddddddd",
"name": "name02",
"description": "mydescription",
"jiraKey": null,
"platform": "Local",
"workspaceName": "workspace2"
}
]
}

 

---------------------------------------------------

In JMeter, there's way as following:

$.data[?(@.jiraKey=="MD")].id
$.data[?(@.jiraKey=="MD")].workspaceId

How about in SIL? 

 

3 answers

0 votes
Andrea Pannitti
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2022

Hi @MeterSphere Demo

you should use fromJson to get the json like an object and then you should get the property like it showed in this documentation page.

Ingo Bultschnieder October 27, 2023

I would love to see the document page, but how do i get access to cprime confluence?

0 votes
Andrea Pannitti
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2022

Hi @MeterSphere Demo,

Just a thing about your json: there is an issue due to the comma near "workspace1" and near "workspace2".
I recommend you to use a Json validator like: JSONLint.

MeterSphere Demo June 8, 2022

Thank you @Andrea Pannitti for pointing it out. I corrected the json. 

This was because I removed part of the content in the original json. 

0 votes
MeterSphere Demo June 8, 2022

removing the wrong comments

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events