Combreal icon

iterateThroughJson.py

Combreal | PRO | 07/29/21 03:11:55 PM UTC (Edited) | 0 ⭐ | 1154 👁️ | Never ⏰ | []
Python |

450 B

|

None

|

0 👍

/

0 👎

import requests
import json
import sys
 
dataJson = '{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}'
 
data = json.loads(dataJson)
 
for item in data["popup"]["menuitem"]:
   print(item.get('onclick'))
 
 
#json compacter : https://jsonformatter.org/e8391c
#pretty print json : print(json.dumps(data, indent=4, sort_keys=True)) 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎