I have a JSON file that looks likes this:
{ "users":"John, admin"}
What I want is to be able to add a string into the "users" title. So, basically, I want to allow users to input a new username and add it to this list. Take the following Python code:
newUserInfo = input("Enter a new username: ")
And then say I input "Michael" Then the JSON file should look like this:
{ "users":"John, admin, Michael"}
I've tried the following:
with open(userFile, "a") as userobj:
newUserInfo = json.dump(allUserInfo["users": newUserInfo], userobj)
And It returns an error. Is there an easy way to do this?
Thanks in advance.
{"users": ["John", "admin"]}would be a much besser format?