Forum Discussion

pushkala's avatar
pushkala
New Contributor
6 years ago

Creating a Nested Json for a REST API Post Request

I am running into a very weird issue.
Big Picture - doing a bunch of operations but finally have to make a REST API call

{"field1": "random_values",
 "field2": [ { "field5": "451037", "field6": "d1"} ],
 "field3": "test",
 "field4": "True"
}

I have generated all the values through various operations - but not sure how to generate the complete payload.

Any pointers.

3 Replies

    • anubhav_nautiya's avatar
      anubhav_nautiya
      Contributor
                     "field": [
                      #set($End = $length)   ## length is length of field array
                      #set($Range =[0..$End])
                      #foreach($i in $Range)
                              {
                              "value": {
                                  "key1":[{"value":$val1[$i]}],
                                  "key2":[{"value":$val2[$i]}]
      
                                  }
                      }
                      #if($i != $End),
      

      #end
      #end
      ]