Combine two JSON Arrays to one

Blen Assefa 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

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

Suggest an answer

Log in or Sign up to answer