Advanced Jira Automation Tips: Mastering JSON Manipulation with Smart Values

Advanced Jira Automation Tips: Mastering JSON Manipulation with Smart Values

Unlock the full potential of JSON data in Atlassian Automation Cloud with these expert techniques.

This guide was inspired and should be fully credited to Christopher from the Atlassian Team as this information is lacking depth in the documentation and has enlightened some key points in automation inconsistencies for me.

Introduction

Jira Automation Cloud empowers teams to streamline workflows, but its true power lies in handling complex JSON data. Whether parsing webhook payloads or transforming Jira issue data, smart values and JSON functions enable dynamic automation. This article explores advanced methods to access, filter, and transform JSON data, complete with use cases and actionable tips.

Key Info

1. Log Action for Debugging

Use the Log Action component to output evaluated smart values to the Audit Log. This is critical for troubleshooting expressions.

Example

Output: For testing purposes, you can simple put the JSON example below into a issue description and use the smart value log action above to retrieve that.

We will be using this example JSON provided by Christopher in our testing and learning today.

{
   "message":  {
     "subject": "Test message",
     "participants": {
         "from": "[email protected]",
         "to": [ "[email protected]", "[email protected]" ]
     },
     "attachments": [
         {
            "filename": "attachment1.txt",
            "tags": [ "tag1", "tag2" ],
            "insights": [
                { "type": "quality", "value": "insight1 value" },
                { "type": "safety", "value": "insight2 value" },
                { "type": "safety", "value": "insight5a value" }
            ]
         },
         {
            "filename": "attachment2.txt",
            "tags": [ "tag3", "tag4" ],
            "insights": [
                { "type": "quality", "value": "insight3 value" },
                { "type": "safety", "value": "insight6a value" }
            ]
         }
     ]
   }
}        
{"message":{"subject":"Test message","participants":{"from":"[email protected]","to":["[email protected]","[email protected]"]},"attachments":[{"filename":"attachment1.txt","tags":["tag1","tag2"],"insights":[{"type":"quality","value":"insight1 value"},{"type":"safety","value":"insight2 value"},{"type":"safety","value":"insight5a value"}]},{"filename":"attachment2.txt","tags":["tag3","tag4"],"insights":[{"type":"quality","value":"insight3 value"},{"type":"safety","value":"insight6a value"}]}]}}        

  1. Formatted example JSON
  2. Single-line format to copy paste into an issue description

2. Webhook Data Conversion

Data from Incoming Webhooks is automatically parsed into a JSON object {{webhookData}}

For other sources (e.g., issue descriptions), you can manually convert strings to JSON using jsonStringToObject().


Core Techniques

1. Converting Strings to JSON

Use Case: Parse JSON stored in a Jira issue description, this could be useful for automating email requests that come in with service updates, incidents and requests that use JSON messaging.

Smart Value:

{{jsonStringToObject(issue.description)}}           

Output: A structured JSON object.

{message={subject=Test message, participants={[email protected], to=[[email protected], [email protected]]}, attachments=[{filename=attachment1.txt, tags=[tag1, tag2], insights=[{type=quality, value=insight1 value}, {type=safety, value=insight2 value}, {type=safety, value=insight5a value}]}, {filename=attachment2.txt, tags=[tag3, tag4], insights=[{type=quality, value=insight3 value}, {type=safety, value=insight6a value}]}]}}        


2. Accessing Properties & Arrays

Accessing one value:

Once the string is converted into a JSON object, you can access nested properties directly using a pattern called "Dot Notation"

I like to visualise this in my head as a map route, first stop is "message" then "participants" and the final end destination (the values I want to access) is "from"

Every dot is a new destination point and new values to retrieve.

Smart value:

  {{jsonStringToObject(issue.description).message.participants.from}}          

Output: [email protected]

There is only one value at this destination so there's no problem here, if there were multiple, only the first value would be retrieved.

You could combine other Jira smart value functions like .get(0) to retrieve the exact value you want. Indexing starts at 0.


Accessing a single array with multiple values

Smart value:

{{jsonStringToObject(issue.description).message.participants.to}}        

Output: [email protected], [email protected]

To take this one step further, you can loop through these individual values in the array with a Jira Automation branch

- Array Branching: Loop through arrays (e.g., email recipients).

We have simply put the smart value used above in the branch and now Jira knows to loop through each value automatically.

Now each value that we will branch over (e.g. [email protected]) will be called by the variable name "participantTo".

Note: Jira automation users are allergic to capital letters to start variables.

Log action input:

  Branched Item: PT: {{participantTo}}          

Output: PT: [email protected], PT: [email protected]


Accessing multiple arrays containing multiple values

Building on top of the layers previous seen above, we have a final dilemma of accessing multiple arrays in one JSON destination with multiple values in each

For this example, we will use the tags smart value to branch on, if you ever need a visual refresh, check the JSON bodies at the top of this article again to understand the branching and looping methods along with the value outputs here.

{{jsonStringToObject(issue.description).message.attachments.tags}}        

Output: [tag1, tag2], [tag3, tag4]

Christopher

You can branch into these loop items but they will also be arrays still meaning you cant loop through every element in two arrays through this branch.

Smart value loop item:

TAG_ARRAY: {{tagArray}}        

Output: TAG_ARRAY: tag3, tag4, TAG_ARRAY: tag1, tag2

This would loop twice, that's why you can see the TAG_ARRAY repeated 2 times and these are two arrays not four separate items.


3. Merging Arrays with flatten

Use Case: Aggregate multiple values from multiple arrays into a single list to access each element individually.

Smart Value (for branch):

{{jsonStringToObject(issue.description).message.attachments.tags.flatten}}          

Output: tag1, tag2, tag3, tag4

Christopher

To test this, we will repeat the same log value looping

TAG_ARRAY: {{tagArray}}        

Output: TAG_ARRAY: tag4, TAG_ARRAY: tag2, TAG_ARRAY: tag3, TAG_ARRAY: tag1

This has looped 4 times and now every value can be accessed.


Accessing objects in a nested array

This can also be done for accessing objects in a nested array so we will use the insights destination to demonstrate this one

Smart value:

{{jsonStringToObject(issue.description).message.attachments.insights.flatten}}        

Output:

{type=quality, value=insight1 value}, {type=safety, value=insight2 value}, {type=safety, value=insight5a value}, {type=quality, value=insight3 value}, {type=safety, value=insight6a value}        
Christopher

This enables you to branch through these objects and filter using a condition component.

We can now access the keys in the objects that we are looping over, for example looping through the arrays and only accessing the objects with a type equal to safety

Then log the value key that passes the type condition.

Log message:

Safety: {{myInsightObject.value}}        

Output: Safety: insight2 value, Safety: insight5a value, Safety: insight6a value


4. Filtering Data without branching (Smart values)

Currently, nested branching is not supported, and data within a branch cannot be shared outside of it, limiting its use for filtering.

To work around this limitation, you can filter data while creating the smart value variable using "Create variable."

Let's name the variable safetyinsights.

Use Case: Extract safety insights from nested arrays.

Smart value (for variable):

{{#jsonStringToObject(issue.description).message.attachments.insights.flatten}}{{#if(equals(type, "safety"))}}{{value}}{{^last}},{{/}}{{/}}{{/}}        

Output: insight2 value,insight5a value,insight6a value

This expression filters and returns only the items where the type is equal to "safety".

Reminder: Once created as a variable, it is no longer recognised as an array but as a string/text. To convert it back into an array for branching, use the split function.

{{safetyInsights.split(",")}}        

You can now access each item within the branch using the variable name above.

Smart value and log message:

Item:{{singleSafetyInsight}}        

Output: Item:insight5a value, Item:insight2 value, Item:insight6a value


Watch for Spaces in Expressions

Unintended spaces in smart values create artifacts. For example:

{{value}} {{^last}}, {{/}}  // Adds a space before the comma!          

Result: insight2 value , insight5a value

Strengths & Use Cases

Why These Methods Matter

Efficiency: Reduce manual data parsing.

Flexibility: Handle nested JSON structures from APIs, webhooks, or Jira fields.

Scalability: Process large datasets (e.g., attachments, user lists).

Real-World Applications

1. Auto-Tag Issue: Extract tags from JSON and apply them to Jira issues.

2. Dynamic Notifications: Parse webhook data to notify specific participants.

3. Report Generation: Aggregate insights from multiple attachments into a summary comment.

For me personally, I have found this very useful for parsing Jira issue entity properties, API payloads and webhooks, its a common problem I have encountered to parse multiple layers down into a JSON object.

Through knowing these advanced methods we can reduce external tools and keep everything inside Atlassian.


Final Tips

1. Validate JSON Syntax: Use tools like JSONLint to avoid parsing errors when using JSON objects.

2. Leverage Dot Notation and smart value functions: Simplify access to deeply nested properties.

3. Test Iteratively: Use the Log Action to validate each step.


By mastering these techniques, you’ll unlock advanced automation scenarios, reduce manual effort, and create more responsive workflows in Jira. Start small, experiment with the Audit Log, and scale your automation to new heights!

References for this article came from Christopher Atlassian forum article and my own testing.


Elegance Group - Atlassian Platinum Partner

Proudly sponsored by Elegance Group, a distinguished Atlassian partner recognised globally and awarded Partner of the Year in 2022 and still conducting elegant solutions.

For expert Licensing or Services from an acclaimed Atlassian Partner, reach out to Elegance Group. Book a meeting with us to enhance your business with our unparalleled Atlassian solutions.


Lorenzzi Bassoto

Tooling Lead | Atlassian Architect | Technical Leadership | ITSM | Solutions Refactoring | Application Manager | Jira Specialist

3 天前

Very interesting guide ! Looks like im going to have a fun weekend !

Kiet ?Ngo

Helping businesses unlock the full potential of their software investment: Atlassian, HubSpot, Google

3 天前

Atlassian should add more helper functions like this to Jira Automation to keep up with other low-code platforms like Zapier, n8n...

要查看或添加评论,请登录

Brandon Davies的更多文章