Relatively new to JSON and Python here. Trying to make a function that adds a new entry to a JSON-file. The JSON-file (avutstyr.json) looks like this:
{
"Utstyr":
[
{
"id": "SKMU0001",
"name": "Panasonic XY1234",
"type": "Projektor 4:3"
},
{
"id": "SKMU0002",
"name": "PA uten miksebord",
"type": "PA-system"
}
]
}
And the Python-script:
newequip = """{
"id": "SKMU0003",
"name": "Panasonic CT1212",
"type": "Projektor 16:10"
}"""
is_json(newequip)
newequip = json.loads(newequip)
print(newequip)
with open('avutstyr.json', 'a+') as f:
data = json.load(f)
data = data['Utstyr'].update(newequip)
json.dump(data, f)
for i in data['Utstyr']:
print(i['name'])
Getting the following error: JSONDecodeError: Expecting value
The values are there or what?