Start with the dictionary in Python, first with the empty dictionary eth, where you add the data eth0,eth1 and correspond to two IP
>>> eth = {}
>>> eth[' eth0 '] = ' 192.168.2.12′
>>> Print ETH
{' eth0′: ' 192.168.2.12′}
>>> eth[' eth1 '] = ' 223.5.5.5′
>>> Print ETH
{' eth1′: ' 223.5.5.5′, ' eth0′: ' 192.168.2.12′}
JSON converts to dict in Python, converting dict to json-using Json.dumps (), converting JSON to dict-using Json.loads ()
>>> Import JSON
>>> Ethjson = Json.dumps (ETH)
>>> type (Ethjson)
>>> Print Ethjson
{"Eth1″:" 223.5.5.5″, "Eth0″:" 192.168.2.12″}
>>> ethdict = json.loads (Ethjson)
>>> type (ethdict)
>>> Print Ethdict
{u ' eth1′: U ' 223.5.5.5′, u ' eth0′: U ' 192.168.2.12′}
>>> print ethdict[' eth0 '], ethdict[' eth1 ']
192.168.2.12 223.5.5.5
To determine if there is a key in JSON
If ' text ' in post[' caption '].keys ():
If ' text ' in post[' caption ']:
If ' ipv4′in output[' ansible_facts '][ansible_int]: