MasPutraWae

Json

Python - Baca dan Tulis Pada File Json

Python punya standar library untuk mengelola Json. Cara Penggunaannya Untuk membuka file.json di python import json with open("data.json", "r") as file: data = json.load(file) print(data) Dan ini cara simpan ke file Json import json data = [ { "nama": "Putra", "usia": 17, "active": True }, { "nama": "Upin", "usia": 10, "active": True }, { "nama": "Ipin", "usia": 10, "active": False } ] with open("data.json", "w") as file: json.dump(data, file, indent=4) Terkait Python - Membaca File Toml