I would like to append to an existing json array using python like this:
{
"username": "user",
"password": "password"
}
from this to
{
"username": "user",
"password": "password",
"team name": "testTeam",
"firstplayer": "firstPlayer",
"secondplayer": "secondPlayer",
"thirdplayer": "thirdPlayer",
"fourth Player": "fourthPlayer",
"fifthplayer": "fifthPlayer"
}
this is my current python code
def createTeam():
username = 'user'
password = 'pass'
teamName = 'testTeam' #input('What is your teams name? ')
firstPlayer = 'firstPlayer'#input('Who is your first Player: ')
secondPlayer = 'secondPlayer'#input('Who is your second Player: ')
thirdPlayer = 'thirdPlayer'#input('Who is your third Player: ')
fourthPlayer = 'fourthPlayer'#input('Who is your fourth Player: ')
FifthPlayer = 'fifthPlayer'#input('Who is your fifth Player: ')
f = open("users.json", "r")
users = json.load(f)
x = users['users'].append({'username': username, 'password': password, 'team name': teamName, 'firstplayer': firstPlayer, 'secondplayer': secondPlayer, 'thirdplayer': thirdPlayer, 'fourth Player': fourthPlayer, 'fifthplayer': FifthPlayer})
with open('users.json', 'w') as f:
json.dump(x, f, indent=2)
in short im just trying to update a record like in a database but i don't know how too