Hello there,


I want to parse the body request from this:



to finally send this to the request body:


Basically I should try to transform the 1st request on the OnBeforeRequest event of a consumed REST API, to finally send the 2d request which was parsed. But now I'm facing some trouble to achieve this.


Any help/suggestion will be appreciated.


Thanks.

Hi,

From your question, I am making the assumption that you are sending data to a service. How are you creating the request in the first place?  Your top example is the proper way to send a list of items from 1..N.  If you were trying to post somewhere, they would not know what values to expect if you had random number of elements of type GENERIC_VALUE_1

GENERIC_VALUE_2

GENERIC_VALUE93247


Where would you stop? That is the reason this is usually done in the list/array format.

Hi,

Is that's for the web then I am sure you can use  ardoJSON, which includes the ability to dynamically query for keys.  And yes implementation can be done in OnBeforeRequest :)

Cheers

Hi Elias,

Please check this forge

https://www.outsystems.com/forge/component-overview/7531/jsontoolkit-xif

You can easily add all other attributes in new format but for GENERIC_LIST you have to loop through it and use AddProperty to add attribute and its value for each entry in the loop.

Hi Elias,

I had an error similar to this and I had to handle it manually.

  1. Each element will always check if it is an array or not.

  2. If it is an array, check whether it is a two-dimensional array or a three-dimensional array.

  3. You can get "keyName: value" and push in JSON like you want.


For example: In my case, JSON has three-dimensional array:

_name: "GENARIC_LIST[0].GENERIC_KEY"          >> value1   "GENERIC_VALUE_1"

_name: "GENARIC_LIST[0].GENERIC_VALUE"         >> value2   "VALUE 1"

>> push value1: value2 in JSON

Regards,