Hi, I designed an automation that sends a web request and this is the Json I receive:
{datos=[{field1=abc, number=1234}, {field1=abcd, number=4567}], response={description=null, responseCode=200, responseId=null}}
I created a smart value to read the response and get some data: {{webResponse.body.MetodoPagoOut.datos.number}} and I get this string: 1234, 4567
Is there any way to convert the results into a list? I need to extract each pair of values to create an object, using a branch perhaps.
Thanks,
Franco
Hi @Franco Genga -- Welcome to the Atlassian Community!
Please try using the split() function to split the text into a list: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#split-String-separator-
If that does not help, please post images of your complete rule and the audit log details showing the rule execution. Those will provide context for the community to offer help. Thanks!
Kind regards,
Bill
Hi Bill! Thanks for that response.
I reviewed all the docs and made a lot of tests using smart values for text fields but I still can't resolve it.
What I'm trying to accomplish is to convert this string: "1234, 4567" (now it has only 2 numbers separated by a comma but it could be more in the future) into a collection, so I can use advanced branches, in order to use it as a loop...is it possible? Has anyone could ever resolve this?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This will work using split(",")
Would you please post images of your rule where this does not work as you expect, including images of the action, condition, and branch details, and of the audit log details showing the rule execution?
Please note: sometimes parsing web request responses results in an array rather than a list. There are solutions for that, but let's first see what your rule looks like before investigating that possibility.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do it via the split(", ") string function others have mentioned.
Something that I struggled with was how to access the data in the newly created list. If you are using the # loop construct, you can access it via {{.}}
So, in your example, if you wanted to loop through the list created by split() it would look like:
{{#webResponse.body.MetodoPagoOut.datos.number.split(", ")}}
{{.}}
{{/}}
And the output would be
1234
4567
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.