# Parse a dynamic json response

**URL:** <https://forum.ansible.com/t/parse-a-dynamic-json-response/35514>\
**Category:** Ansible Project\
**Created:** [July 16, 2021, 2:00pm UTC](https://forum.ansible.com/t/parse-a-dynamic-json-response/35514 "2021-07-16T14:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephane\_Cremel](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@Stephane\_Cremel](https://forum.ansible.com/u/Stephane_Cremel)\
**Post date:** [July 16, 2021, 2:00pm UTC](https://forum.ansible.com/t/parse-a-dynamic-json-response/35514/1 "2021-07-16T14:00:00Z")

</div>

I work on role for administrate an elastic cluster.

When i execute this :

- name: Get Statistic of index  
uri:  
url: “{{ update\_index }}”  
method: GET  
body: “”  
body\_format: json  
register: result\_stats  
when: index\_ is defined and index

- debug:  
msg: “{{ index\_ }}”

- debug:  
msg: “{{ result\_stats.json }}”

I have this response :

TASK [elastic\_search\_create\_index : Get Statistic of index] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [vmelastic02.preprod]

TASK [elastic\_search\_create\_index : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [vmelastic02.preprod] =\> {  
“msg”: “webshop-de-preprod”  
}

TASK [elastic\_search\_create\_index : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [vmelastic02.preprod] =\> {  
“msg”: {  
“webshop-de-preprod”: {  
“settings”: {  
“index”: {  
“creation\_date”: “1626441304247”,  
“number\_of\_replicas”: “2”,  
“number\_of\_shards”: “1”,  
“provided\_name”: “webshop-de-preprod”,  
“routing”: {  
“allocation”: {  
“include”: {  
“\_tier\_preference”: “data\_content”  
}  
}  
},  
“uuid”: “hVD9st6VSyiFmTI6pMqjIQ”,  
“version”: {  
“created”: “7130399”  
}  
}  
}  
}  
}  
}

I would like get the value of number\_of\_replicas

but when i test :

- debug:  
msg: “{{ result\_stats.json.{{ index\_ }} }}”

I have an error, how can I do that ?

thanks
