# How to unquote a json structure

**URL:** <https://forum.ansible.com/t/how-to-unquote-a-json-structure/36913>\
**Category:** Ansible Project\
**Created:** [July 28, 2022, 9:59am UTC](https://forum.ansible.com/t/how-to-unquote-a-json-structure/36913 "2022-07-28T09:59:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![actionmystique](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/actionmystique/32/1678_2.png) [@actionmystique](https://forum.ansible.com/u/actionmystique)\
**Post date:** [July 28, 2022, 9:59am UTC](https://forum.ansible.com/t/how-to-unquote-a-json-structure/36913/1 "2022-07-28T09:59:53Z")

</div>

One shell command returns a json structure, but ansible converts it into a string in the registered variable.  
In order to access some attributes, this string needs to be unquoted, but how?  
There is a quote filter, but **there is no unquote filter in ansible or jinja2**.

For instance, let’s suppose a shell module returns the following registered variable:  
return:  
changed: true  
cmd: |-  
cmd\_returning\_json  
delta: ‘0:00:00.002283’  
end: ‘2022-07-28 11:09:17.921175’  
failed: false  
msg: ‘’  
rc: 0  
start: ‘2022-07-28 11:09:17.918892’  
stderr: ‘’  
stderr\_lines:   
stdout: ‘{“class”: “data”, “id”: “a61b96e7-427e-493a-993c-c3efc8a16aa1”, “size”: “500GB”, “type”: “ssd”}’

How do we convert return.stdout into:  
{“class”: “data”, “id”: “a61b96e7-427e-493a-993c-c3efc8a16aa1”, “size”: “500GB”, “type”: “ssd”}

so that we can access for instance:  
return.stdout.id

---

<div class="post-metadata">

**Author:** ![actionmystique](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/actionmystique/32/1678_2.png) [@actionmystique](https://forum.ansible.com/u/actionmystique)\
**Post date:** [July 28, 2022, 10:10am UTC](https://forum.ansible.com/t/how-to-unquote-a-json-structure/36913/2 "2022-07-28T10:10:00Z")

</div>

It turns out there is no need for unquoting.  
In my original issue, the returned structure was much more complex and included some strange **new lines**.  
Removing all new lines with:  
return.stdout | regex\_replace(‘\n’, ‘’)  
solves this issue.
