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.

can you try using a for loop for field2 in JSON generator

Can you please share some examples

               "field": [
                #set($End = $length)   ## length is length of field array
                #set($Range =[0..$End])
                #foreach($i in $Range)
                        "value": {

                #if($i != $End),