/
How to configure the JSON Table macro to manipulate the row data in Confluence

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

  1. Navigate to the app Global configuration page and configure the profile.

    2024-11-12_15-09-22.png
    Profile

     

  2. Insert and configure the JSON table macro, as illustrated below.
    a. Select the configured Profile.

    2024-11-12_15-11-15.png

    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 of lead.active from true/false to image formats. This value will not alter the original column: $lead.active, but adds a new column where the lead.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 the lead.active values. For example, on the page Advanced Tables—JSON table macro augmentation, attach true.png and false.png files. Images attached for reference:

    false.png true.png

    2024-11-12_15-37-38.png
    Attachments

     

    2024-11-12_15-11-51.png
    Data format

     

    2024-11-12_15-12-04.png
    Data settings

     

  3. To display the active projects at the top, apply the settings as shown below:

    2024-11-12_15-26-42.png
    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>

  4. 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.

    2024-11-12_15-28-14.png

     

Related content