How to configure the JSON Table macro to manipulate the row data in Confluence
This article provides a step-by-step guide to configuring the JSON Table macro in Confluence to augment data row values.
It demonstrates how to display Jira project statuses (active/inactive) as image icons, replacing raw boolean values (true/false) for a more intuitive display.
Requirement
To display the state of Jira projects (i.e., active/inactive) on Confluence pages using the Jira REST API: <Base_URL>/rest/api/2/project?expand=lead
. Here is the sample data:
{
"expand": "description,lead,url,projectKeys",
"self": "<BASE_URL>/rest/api/2/project/92817",
"id": "92817",
"key": "CREAT",
"lead": {
"self": "<BASE_URL>/rest/api/2/user?username=automation",
"key": "automation",
"name": "automation",
"avatarUrls": {
"48x48": "<BASE_URL>/secure/useravatar?avatarId=10062",
"24x24": "<BASE_URL>/secure/useravatar?size=small&avatarId=10062",
"16x16": "<BASE_URL>/secure/useravatar?size=xsmall&avatarId=10062",
"32x32": "<BASE_URL>/secure/useravatar?size=medium&avatarId=10062"
},
"displayName": "Automation",
"active": true
},
"name": ":createProjectC",
"avatarUrls": {
"48x48": "<BASE_URL>/secure/projectavatar?avatarId=10264",
"24x24": "<BASE_URL>/secure/projectavatar?size=small&avatarId=10264",
"16x16": "<BASE_URL>/secure/projectavatar?size=xsmall&avatarId=10264",
"32x32": "<BASE_URL>/secure/projectavatar?size=medium&avatarId=10264"
},
"projectTypeKey": "software",
"archived": false
}
The expected outcome is to represent lead.active
as “active” or “inactive” rather than displaying it as true
or false
.
Instructions
Navigate to the app Global configuration page and configure the profile.
ProfileInsert and configure the JSON table macro, as illustrated below.
a. Select the configured Profile.b. Configure the Path to fields and Augment field section as given below:
Paths to fields: $ Paths to fields to be included: $.key, $.name, $.lead.active, $.projectTypeKey Augments to data row values: ,,,!Advanced Tables - JSON table macro augmentation^%lead.active%.png!, Augments to heading row values: ,,Status,Image Columns to display: key,name,lead.active,Image,projectTypeKey
The Augments to data row values have a new column parameter!Advanced Tables - JSON table macro augmentation^%lead.active%.png!
. This is a replacement parameter that will replace the value oflead.active
from true/false to image formats. This value will not alter the original column: $lead.active, but adds a new column where thelead.active
values are represented as images instead of text.
To render the data in image formats, attach two images with the exact naming convention of thelead.active
values. For example, on the page Advanced Tables—JSON table macro augmentation, attach true.png and false.png files. Images attached for reference:AttachmentsData formatData settingsTo display the active projects at the top, apply the settings as shown below:
Sorting
Here is the Storage format for quick reference:<p><br /></p> <p>Get the Jira Project details from <a href="<BASE_URL>/rest/api/2/project?expand=lead"><BASE_URL>/rest/api/2/project?expand=lead</a> and display them in JSON table macro. </p> <p>Use the augmentation to replace the text on a certain column. For example, the lead.active returns true/false( representing the project status: Active / Inactive). To help users understand, one can replace/duplicate the original column to show the desired text in the image format as shown below.</p> <p><br /></p><ac:structured-macro ac:name="json-table" ac:schema-version="1" ac:macro-id="85e18df5-d88b-41d8-a077-c767ac960693"><ac:parameter ac:name="output">wiki</ac:parameter><ac:parameter ac:name="sortDescending">true</ac:parameter><ac:parameter ac:name="fieldPaths">$.key, $.name, $.lead.active, $.projectTypeKey</ac:parameter><ac:parameter ac:name="sortColumn">Status</ac:parameter><ac:parameter ac:name="columns">key,name,lead.active,Image,projectTypeKey</ac:parameter><ac:parameter ac:name="paths">$</ac:parameter><ac:parameter ac:name="profile">Jira Max</ac:parameter><ac:parameter ac:name="headingAugments">,,Status,Image</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:parameter ac:name="augments">,,,!Advanced Tables - JSON table macro augmentation^%lead.active%.png!,</ac:parameter></ac:structured-macro> <p><br /></p> <p><br /></p> <div class="table-wrap"><br /></div><ac:structured-macro ac:name="json-table" ac:schema-version="1" ac:macro-id="6783c445-589e-43ad-b57f-a01560c6f51b"><ac:parameter ac:name="output">wiki</ac:parameter><ac:parameter ac:name="sortDescending">true</ac:parameter><ac:parameter ac:name="fieldPaths">$.key, $.name, $.lead.active, $.projectTypeKey</ac:parameter><ac:parameter ac:name="sortColumn">Status</ac:parameter><ac:parameter ac:name="columns">key,name,lead.active,Image,projectTypeKey</ac:parameter><ac:parameter ac:name="paths">$</ac:parameter><ac:parameter ac:name="profile">Jira Max</ac:parameter><ac:parameter ac:name="headingAugments">,,Status,Image</ac:parameter><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:parameter ac:name="augments">,,,!Advanced Tables - JSON table macro augmentation^%lead.active%.png!,</ac:parameter></ac:structured-macro> <div class="table-wrap"><br /></div> <p><br /></p>
Save the macro and update the page to view the result. As you see, the project status (active/inactive) is now displayed as image icons.