# ansible 1.8.2: json is not parsed from uri result..

**URL:** <https://forum.ansible.com/t/ansible-1-8-2-json-is-not-parsed-from-uri-result/17206>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [January 7, 2015, 1:38pm UTC](https://forum.ansible.com/t/ansible-1-8-2-json-is-not-parsed-from-uri-result/17206 "2015-01-07T13:38:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sascha.lucas](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@sascha.lucas](https://forum.ansible.com/u/sascha.lucas)\
**Post date:** [January 7, 2015, 1:38pm UTC](https://forum.ansible.com/t/ansible-1-8-2-json-is-not-parsed-from-uri-result/17206/1 "2015-01-07T13:38:28Z")

</div>

Hi,

> I don't see json property in configuration... Most probably the reason is that the return type is not "ansible/json" but  
> ...  
> "content\_type": "application/json; charset=UTF-8",

If your HTTP-Server returns a header named 'content\_type' that starts with 'application/json' the URI module should parse the response body into the structure 'json'

The URI modules python code looks like this:

&nbsp;&nbsp;&nbsp;if 'content\_type' in uresp:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if uresp['content\_type'].startswith('application/json'):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;js = json.loads(content)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uresp['json'] = js

May be you hit a BUG, where json.loads(content) fails to parse, because the response body contains json-escapes. See PR #537 [1] how to fix this.

Thanks, Sascha.

[1] [https://github.com/ansible/ansible-modules-core/pull/537](https://github.com/ansible/ansible-modules-core/pull/537)

Aufsichtsratsvorsitzender: Herbert Vogel  
Geschäftsführung: Michael Krüger  
Sitz der Gesellschaft: Halle/Saale  
Registergericht: Amtsgericht Stendal | Handelsregister-Nr. HRB 208414  
UST-ID-Nr. DE 158253683

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Empfänger sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail oder des Inhalts dieser Mail sind nicht gestattet. Diese Kommunikation per E-Mail ist nicht gegen den Zugriff durch Dritte geschützt. Die GISA GmbH haftet ausdrücklich nicht für den Inhalt und die Vollständigkeit von E-Mails und den gegebenenfalls daraus entstehenden Schaden. Sollte trotz der bestehenden Viren-Schutzprogramme durch diese E-Mail ein Virus in Ihr System gelangen, so haftet die GISA GmbH - soweit gesetzlich zulässig - nicht für die hieraus entstehenden Schäden.
