On 11. juli 2016 15:07, Dader Grund wrote:
i have a  nested json file like :
{
         "fw1": {
                 "ipv4": {
                         "rtr": {
                                 "ip": "1.2.3.4",
                                 "net": "1.2.3.4",

                         }
                 }
         },
         "fw2": {
                 "ipv4": {
                         "rtr": {
                                 "ip": "4.3.2.1",
                                 "net": "4.3.2.1",

                         }
                 }
         }
}


How could i parse in this case only the "ip" value of "fw2" ?
for a non nested json dictionary this phrase has worked for me

{{ (lookup('file', '/etc/foo.txt') | from_json).get('ip') }}.

{{ (lookup('file', '/etc/foo.txt') | from_json)['fw2']['ipv4']['rtr']['ip'] }}

or

{{ (lookup('file', '/etc/foo.txt') | from_json).fw2.ipv4.rtr.ip }}

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5783BE2A.9090108%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to