Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Summary -
Status | ||||
---|---|---|---|---|
|
When using some Custom Fields they may return a JSON Object as the value which made it difficult to extract the relevant value. Within JEMH 4.1.27 we have added a new method to jemhUtils which allows to manipulate JSON values more easily. This page will highlight how to extract specific information from the JSON Object.
Converting a Custom Field value into a JSON value
When we gather the value from the Custom Field it will be returned as a String value which means that it is currently not possible to manipulate the JSON data. To be able to access the JSON data you will need to use the following command to convert the Text value into a JSON value.
...
Code Block |
---|
$jemhUtils.createJSONFromSource($issue.getCustomFieldValue("customfield_10233")) |
Extracting a Specific Object value
To extract a specific Object you will simply need to add the object name to the above and this will return the value/s for that object.e.g.
...
Code Block |
---|
{"object": { "name": "test", "array": { "name": "Array Item1", "id": "10003", }, } } |
Extracting a specific value from a JSON Array
Sometimes the JSON object may contain an array for a specific object. To access the array value you must specify the Array to get the value by using .get()
and then specifying the Array number e.g. below will return the name that is found within first array in the list (e.g.Array Item1
)
...