How to loop JSON of API CALL - Ansible

Hello all, I have an API call, called by Ansible module. I want that this JSON loop ‘n’ times with differents values. This is the JSON:

{
 "name": "{{hostname}}",
 "links": [
    {
      "href": "https://xxxxxxxxxx.ixxi-servicios.com/api/admin/enterprises/2",
      "rel": "enterprise"
    },
    {
      "href": "https://cxxxxxxter.xxxx-serxxxvicios.com/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/{{id_template.stdout}}",
      "rel": "virtualmachinetemplate"
    },
    {
       "title":"{{ip}}",
       "rel":"nic1",
       "type":"xxxx/vnd.xxxxx.externalip+json",
       "href": "https://xxxxxx.xxxx-xxxxxx.com:443/api/admin/enterprises/2/limits/2/externalnetworks/{{id_vlan.stdout}}/ips/{{id_ip.stdout}}"
     }
  ],
"variables": {
      "net-ip0": "{{ip}}",
      "net-mask0": "{{netmask}}",
      "net-gw0": "{{gateway}}",
      "hostname": "{{hostname}}"
},
 "ram": "{{ram}}",
 "cpu": "{{cpu}}",
 "description": "{{hostname}}"
}

The values that must vary the value are:

  • {{id_template.stdout}}
  • {{id_vlan.stdout}}
  • {{id_ip.stdout}}
  • {{ip}}
  • {{netmask}}
  • {{gateway}}

I will use this to add some ethernet interfaces into VM. This vars are defined in other file like this:

hostname: 'prueba'
cpu: '1'
ram: '1024'
template: 'CENTOS_6.5_AUTO'

nic:
- nic: nic1
  ip: '192.168.1.1'
  netmask: '255.255.255.192'
  gateway: '192.168.1.1'
  vlan: 'vlan1'
- nic: nic2
  ip: '192.168.1.2'
  netmask: '255.255.255.192'
  gateway: '192.168.1.4'
  vlan: 'vlan2'

The loop should be use this information to insert in the JSON this vars as many times as the number of nic we have.

any ideas?