Jira Automation smart value
asJsonString and JSON arrays in Jira Automation: examples
These functions turn field values into JSON literals, so you can build the body of a web request without breaking it on quotes or line breaks. asJsonString wraps one text value in quotes and escapes it. asJsonStringArray and asJsonArray write a list as a JSON array.
Syntax
{{text.asJsonString}}
{{list.asJsonStringArray}}
{{list.asJsonArray}}
Works on
- Fields: text values for asJsonString, lists of text or numbers for asJsonStringArray, lists of numbers for asJsonArray.
- Returns: a JSON string or a JSON array, written as text.
Examples
{"text": {{issue.description.asJsonString}}}Put the description in a JSON body. The quotes come from the function, so none are typed around it.
Result:
{"text": "Checkout page redesign. Customer reported the total is wrong."}Run on Jira Cloud on .
{"summary": {{issue.summary.concat(" says \"hi\"").asJsonString}}}Quotes inside the text are escaped, so the body stays valid JSON.
Result:
{"summary": "Hello World! says \"hi\""}Run on Jira Cloud on .
{{issue.labels.asJsonStringArray}}Write the labels as a JSON array of strings.
Result:
["checkout","demo"]Run on Jira Cloud on .
{"labels": {{issue.labels.asJsonStringArray}}}Place the array as a field of a request body.
Result:
{"labels": ["checkout","demo"]}Run on Jira Cloud on .
{{issue.comments.id.asJsonArray}}Write numeric ids as a JSON array of numbers, without quotes.
Result:
[10411,10412]Run on Jira Cloud on .
{{issue.comments.id.asJsonStringArray}}The same ids as an array of strings, for an API that expects ids in quotes.
Result:
["10411","10412"]Run on Jira Cloud on .
Pitfalls
- asJsonArray is for numbers. On text it leaves the quotes out:
{{issue.labels.asJsonArray}}gives[checkout,demo], which is not valid JSON (checked on Jira Cloud, November 2026). ChainasJsonString.asJsonArrayor use asJsonStringArray. - asJsonString on an empty value gives an empty string, not
"". A body such as{"version": {{issue.fixVersions.first.name.asJsonString}}}becomes invalid JSON on a work item without versions, while asJsonStringArray gives[]on an empty list. - Do not type quotes around asJsonString: the function adds them, as the first example shows.
Related
- asJsonObject(), xmlToJson(), jsonStringToObject()
- htmlEncode, xmlEncode, jsonEncode and quote()
- join()
- split()
- {{issue.key}}, {{issue.summary}} and other issue fields