Web API to processParameter

Hello all,

I want to send the following body from Web API to Process Model, I need to change the format as shown below, 

Web API Code:

{
"references": {
"ABC": "111",
"DEF": "222",
"GHI": "333",
"JKL": "444",
"other": {"MNO-555", "XYZ-123", "PQR-666"}
}
}

Change this to the following format:

[ref_text=111, refSource_text=ABC],
[ref_text=222, refSource_text=DEF],
[ref_text=333, refSource_text=GHI],
[ref_text=444, refSource_text=JKL],
[ref_text=555, refSource_text=MNO],
[ref_text=123, refSource_text=XYZ],
[ref_text=666, refSource_text=PQR]

Appreciate if anyone can help me in resolving it, thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • Getting the values form the "other" segment of the data is pretty straightforward:

    a!forEach(
        items: local!myData.references.other,
        expression: 
          with(
            local!nameValues: fn!split(fv!item,"-"),
            {
              ref_text: local!nameValues[2],
              refSource_text: local!nameValues[1]
            }
          )

    The issue is with the first set of data in the array in that you would need to set up a loop to process the items but unless they're always going to have the same 'label' in their label:value pair we can't extract the label and value from the individual item. Unless you can tell me you know in advance what the list of dictionary labels would be for any given instance of the data?

Reply
  • Getting the values form the "other" segment of the data is pretty straightforward:

    a!forEach(
        items: local!myData.references.other,
        expression: 
          with(
            local!nameValues: fn!split(fv!item,"-"),
            {
              ref_text: local!nameValues[2],
              refSource_text: local!nameValues[1]
            }
          )

    The issue is with the first set of data in the array in that you would need to set up a loop to process the items but unless they're always going to have the same 'label' in their label:value pair we can't extract the label and value from the individual item. Unless you can tell me you know in advance what the list of dictionary labels would be for any given instance of the data?

Children