The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Combine two JSON Arrays to one

Blen Assefa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 21, 2021

Hi,

I was wondering if I could get some help in combining two JSONArrays into one for a PUT request in my automation. I have fetched some data from my URL using a webhook. I have stored the JsonArray to a variable. I want to combine the fetched array with an issue field and update it using a new webhook URL.

 

I would like to:

{{webhookResponse.attendees}} combined with {{issue.email}}

The {{webhookResponse.attendees}} is a JsonArray and the  {{issue.email}} is a string to be added into the JsonArray

 

For Example:

Two Arrays.

[
  {
    "productcode":"IRECP",
    "FreeStock":"5",
    "ExpectedStock":""
  },
  {
    "productcode":"N10001",
    "FreeStock":"0",
    "ExpectedStock":""
    }
]

[
  {
    "productcode":"EK20",
    "FreeStock":"1.00",
    "ExpectedStock":"20.00"
  },
  {
    "productcode":"EL50",
    "FreeStock":"-8.00",
    "ExpectedStock":"299.00"
  }
]

 

Desired Result would be one array containing both arrays.

[
  {
    "productcode":"IRE10030CP",
    "FreeStock":"5",
    "ExpectedStock":""
  },
  {
    "productcode":"NIK10001",
    "FreeStock":"0",
    "ExpectedStock":""
    },

  {
    "productcode":"EK219SV150",
    "FreeStock":"1.00",
    "ExpectedStock":"20.00"
  },
  {
    "productcode":"ELTHMC50",
    "FreeStock":"-8.00",
    "ExpectedStock":"299.00"
  }
]

 

 

Thanks

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Bill Sheboy
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 Champions.
July 21, 2021

Hi @Blen Assefa  -- Welcome to the Atlassian Community!

I do not know of any built-in JSON array merging for automation, but I expect you could use the text (string) and list functions to perform the merge.  Please look here for more information:

Best regards,
Bill