Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
418 B
1
Indexable
Never
import json

def create_json_file(path, obj):
    with open(path, 'w') as fh:
        json.dump(obj, fh)


j = {"menu": {
    "id": "file",
    "value": "File",
    "popup": {
        "menuitem":[
            {"value": "New","onclick":"CreateNewDoc"},
            {"value":"Open","onclick": "OpenDoc"},
            {"value":"Close","onclick": "CloseDoc"}
          ]
        }
    }}

create_json_file('test.json', j)