How to append a JSON array with repeating set of values in BPEL.

 

In order to append the JSON array with JSON objects we need to use push function which will iterate through the loop and hold the value in the global variable.

Below is the sample JSON

{

               " version": 100,

               " id": 17

            },

            {

               "product_version": 1,

               " id": 181

            },

            {

               " version": 100,

               " id": 15

            }

}

For each product and version the for loop will iterate and store value in variable A and the JSON object in A is overwritten with every iteration.

In order to Append the JSON array for all the three responses from above combination of ID and version we need the following function in javascript activity of BPEL.

process.B.push(scope.A). Here B is a global variable which will hold values and A is local variable in the for each scope which will fetch the value in every iteration.

 

Comments