N
N
nnikolyaa2020-06-28 12:04:44
Python
nnikolyaa, 2020-06-28 12:04:44

How to add json file?

For example, I have a test.json file.
I need to add values ​​\u200b\u200bto the file with each new user

"Vk_id"={
"nick"=" "
"vip_status"=false
"words"=195
}

How can I add some additional value to Vk_id. And how do I create "Vk_id2"? And also for example how to change "vip_status" to true

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2020-06-28
@fox_12

Pashenka has already written a solution for you in a comment:
1. Read the file
2. Using json.loads, convert to dict
3. Add
4. Convert to json using json.dumps
5. Write to file
And in the example that you gave - json is invalid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question