# Regarding json query in ansible

**URL:** <https://forum.ansible.com/t/regarding-json-query-in-ansible/34613>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 11, 2021, 8:18pm UTC](https://forum.ansible.com/t/regarding-json-query-in-ansible/34613 "2021-02-11T20:18:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_Sharma1](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@Deepak\_Sharma1](https://forum.ansible.com/u/Deepak_Sharma1)\
**Post date:** [February 11, 2021, 8:18pm UTC](https://forum.ansible.com/t/regarding-json-query-in-ansible/34613/1 "2021-02-11T20:18:29Z")

</div>

Hi All,

I am facing an issue with the JSON query to get value to one variable . Code and Ansible output is given below . Response of JSON is coming as null .

- name: print user and password  
debug:  
msg: “Start\_result= {{ ssm\_parameter }}”

- name: save the Json data to a Variable as a Fact  
set\_fact:  
jsondata: “{{ ssm\_parameter.stdout | from\_json }}”

- name: setDomainName  
set\_fact:  
DPM\_password: “{{ jsondata | json\_query(?key==‘SecretString.SB\_password’) }}”  
vars:  
#jmesquery: “[jsondata.SecretString]”  
#query: “[?key==‘{{ project\_environment }}’].value.current”

- name: print user and password  
debug:  
msg: “Start\_result= {{ jsondata | json\_query(‘SecretString.SB\_\_password’) }}”

```auto
SK [ssmpassword : save the Json data to a Variable as a Fact] ****************
task path: /opt/jenkins/workspace/PROJECTS/hello/General/SSMpassword/ansible/playbooks/roles/ssmpassword/tasks/main.yml:12
ok: [[xxxx.abc.com](http://xxxx.abc.com)] => {"ansible_facts": {"jsondata": {"ARN": "arn:aws:secretsmanager:us-west-1:1234:secret:Test_Hello-sgoCgf", "CreatedDate": 1612884866.834, "Name": "Test_Hello", "SecretString": "{\"SB__password\":\"Hello123!1\"}", "VersionId": "ad811140-b5d6-461b-9838-37a750bf8209", "VersionStages": ["AWSCURRENT"]}}, "changed": false}

TASK [ssmpassword : setDomainName] *********************************************
task path: /opt/jenkins/workspace/PROJECTS/hello/General/SSMpassword/ansible/playbooks/roles/ssmpassword/tasks/main.yml:16
ok: [[xxxx.abc.com](http://xxxx.abc.com)] => {"ansible_facts": {"SB_password": ""}, "changed": false}

TASK [ssmpassword : print user and password] ***********************************
task path: /opt/jenkins/workspace/PROJECTS/hello/General/SSMpassword/ansible/playbooks/roles/ssmpassword/tasks/main.yml:24
ok: [[xxxx.abc.com](http://xxxx.abc.com)] => {
    "msg": "Start_result= "

```

```auto

```

```auto
Pleae guide me it is urgent .

```

```auto

```

```auto
Regards,

```

```auto
Deepak

```

```auto

```

```auto

```
