jsonStringToObject() not returning expected results

David Corlette
Contributor
January 14, 2025

Has anyone used jsonStringToObject() successfully? This documentation: 

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#jsonStringToObject--

uses the example code 

{{jsonStringToObject(webResponse.body)}}

and claims that that can then be addressed using dot notation, but within Confluence automation I've tried

{{jsonStringToObject(page.body)}}

or for example

{{jsonStringToObject(page.body).type}} (which should return "doc")

and nothing is returned.

{{page.body}}, on its own, returns a string that validates as proper JSON text - so this SHOULD work. I.e. this appears to be a bug.

Speaking of which, the object {{page.body}} seems to be entirely undocumented - I know {{page.body.storage}} works, but I have not been able to find any other sub-elements of {{page.body}}. Any hints?

Background here is that I'm trying to iterate through the rows of a table, and what I'd LIKE to do is to return the rows as a "list" that I can then iterate using Automation's "FOR EACH" - otherwise I'll have to have 50+ IF clauses and use string extraction to grab each table row.

2 answers

0 votes
Marc - Devoteam
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.
January 14, 2025

Hi @David Corlette 

These smart value functions are only for automation in Jira.

Automation is not a product that acts the same as in Confluence and Jira.

Both products have automation, but have there own smart values as well.

https://support.atlassian.com/cloud-automation/docs/smart-values-in-confluence-automation/ 

In the API docs body is named, but not in any detail.

I have seen people access the page body in an automation rule by using the Confluence REST API together with the "Send web request" action.

You can access the HTTP response in later components with the {{webRequest.body}} smart value. So you could potentially use that smart value in a comparison condition to achieve your use case.

David Corlette
Contributor
January 14, 2025

Thanks for the response. You may be on to something - {{page.body}} just returns text, so you would ASSUME that Atlassian would make the same text operators available - but maybe, inexplicably, they have not. I get that Jira and Confluence have different objects and hence different smart values - but again, this is just text, it would be my expectation that the same functions would be available.

I'll also note that the automation doesn't throw an error of any sort, like "jsonStringToObject()  not supported" or anything USEFUL. So.

As for the {{page.body}} smart value itself, it definitely exists and will log text to the Audit log if you ask it to. You don't need to run a web request to get it. Other folks have mentioned it in other solutions, but it appears to not be documented.

So, I guess I'd say:

1. {{page.body}} definitely exists and will log text results

2. Although jsonStringToObject() isn't explicitly documented in the Confluence smart value documentation, NONE of the strong operators are - and yet many of them work, such as substringBetween() and so forth - so they clearly exist, but Atlassian has not gotten around to documenting them yet.

3. I would expect the set of string manipulation operators to be the same across Jira/Confluence, since it's a base type not something specific to either platform. Anything else would violate the principle of least surprise.

4. Since this function seems to silently fail without producing expected results (either a JSON object or an error), I would suggest this should be classified as a bug.

0 votes
Łukasz Modzelewski _Lumo_
Atlassian Partner
January 14, 2025

Based on the link and the tags in your request, it seems that the issue might be caused by trying to use Jira Automation smart values in Confluence Automation.

I couldn’t find the exact smart value you're using in the Confluence documentation:  https://support.atlassian.com/cloud-automation/docs/smart-values-in-confluence-automation/ 

However, take a look- you might find something that better matches your needs.

David Corlette
Contributor
January 14, 2025

Same reply as to Marc, above - could be a difference in platform, but really it seems like Confluence just hasn't caught up yet in the doco department. Strings are strings. Seems like a bug to me.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events