'How do I replace the key in a JSON file?
Could you please tell me how can I replace the key in a JSON file?
JSON file structure:
[
{
"id" : "365",
"credits" : [ {
"login" : "user1",
"password" : "pa$$w0rd"
} ]
}, {
"id" : "366",
"credits" : [ {
"Login" : "user2",
"password" : "pa$$w0rd"
} ]
}
]
it is necessary that the login key be of the same type, i.e. with one register throughout the document, all Login keys become login.
This is necessary for further analysis and downloading of information from the JSON file.
with open ("test.json", "r") as read_file_json:
data_json = json.load(read_file_json)
for n in range(len(data_json)):
id = (data_json[n]['id'])
id = str(id)
for credits in data_json[n]["credits"]:
login = credits["login"]
Thank you very much!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
