Hey guys!
I’m pretty new to python and i’m trying to learn it, so i began a simple project that exports users from my database to a json file.
I however ran in to an issue where it added characters i can’t seem to remove.
As a preview of my code;;
memberinfo_obj ={
memberID:{
"guid": guid,
"id": memberID,
"type": "player",
"avatar": avatarurl,
"last_username": username,
"joined_at": joined,
}
}
json.dump(memberinfo_obj, memberfile, indent = 4)
It creates the json file just how i want to have it.
However for some reason addition
The output of this is like this:
{
"6907364934": {
"guid": "941745",
"id": "6907364934",
"type": "player",
"avatar": "https://www.kindpng.com/picc/m/78-786207_user-avatar-png-user-avatar-icon-png-transparent.png",
"last_username": "King11",
"joined_at": "2022-02-11T17:20:39.303000+00:00"
}
}{
"395551754": {
"guid": "941745",
"id": "395551754",
"type": "player",
"avatar": "https://www.kindpng.com/picc/m/78-786207_user-avatar-png-user-avatar-icon-png-transparent.png",
"last_username": "Jezia",
"joined_at": "2022-03-02T10:36:29.432000+00:00"
}
}{
"195551754": {
"guid": "941745",
"id": "195551754",
"type": "admin",
"avatar": "https://www.kindpng.com/picc/m/78-786207_user-avatar-png-user-avatar-icon-png-transparent.png",
"last_username": "illinux",
"joined_at": "2022-01-011T10:36:29.432000+00:00"
}
}
As you can see it places additional }{'s in there.
I need to replace these with a , to make it a valid json file.
Can anyone tell me what i’ve done wrong? I have no idea what i did wrong.