# parsing output from json

**URL:** <https://forum.ansible.com/t/parsing-output-from-json/25085>\
**Category:** Ansible Project\
**Created:** [July 25, 2017, 9:03pm UTC](https://forum.ansible.com/t/parsing-output-from-json/25085 "2017-07-25T21:03:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![akku1](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@akku1](https://forum.ansible.com/u/akku1)\
**Post date:** [July 25, 2017, 9:03pm UTC](https://forum.ansible.com/t/parsing-output-from-json/25085/1 "2017-07-25T21:03:25Z")

</div>

ansible --version  
ansible 2.2.1.0  
config file = /etc/ansible/ansible.cfg

Am using find modules to get largest files and its size the file, I am getting a big jason format output, How can i parse one particular string from the output.

# I need to fetch only the “path” and “size” values from here. Can anyone help me on this?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 26, 2017, 5:49am UTC](https://forum.ansible.com/t/parsing-output-from-json/25085/2 "2017-07-26T05:49:57Z")

</div>

How, depends on what you are going to do with path and size, so this is one of several ways.

&nbsp;&nbsp;&nbsp;- debug: msg="{{ item.path }} - {{ item.size }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items: "{{ logfile.files }}"

---

<div class="post-metadata">

**Author:** ![akku1](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@akku1](https://forum.ansible.com/u/akku1)\
**Post date:** [July 26, 2017, 12:03pm UTC](https://forum.ansible.com/t/parsing-output-from-json/25085/3 "2017-07-26T12:03:25Z")

</div>

yes… with this it prints the path and size along with the whole output. but i need only the parsed output.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 26, 2017, 12:44pm UTC](https://forum.ansible.com/t/parsing-output-from-json/25085/4 "2017-07-26T12:44:33Z")

</div>

You don't say what you are going to use this for.  
If you would like it in a file, use the template module.

If you would like to have it displayed nice on the screen you are probably using the wrong tool.  
Ansible is not a reporting tool but a configuration management tool.  
But you could write your one callback plugin to make the output the way you want it to be.

---

<div class="post-metadata">

**Author:** ![akku1](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@akku1](https://forum.ansible.com/u/akku1)\
**Post date:** [July 26, 2017, 8:55pm UTC](https://forum.ansible.com/t/parsing-output-from-json/25085/5 "2017-07-26T20:55:19Z")

</div>

The idea is to delete the file…  
I need the formatted output, because my associated application is expecting such an input from ansible…  
thanks for the info…
