P
P
pthon2019-12-23 22:52:22
Python
pthon, 2019-12-23 22:52:22

How to complete a record in JSON?

Hello!
There is a Json file with an entry like this:

"bannedUsers" : {
  "ID" : "575656567"
}

how to add another "ID"?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
antonksa, 2019-12-23
@antonksa

You are probably already the ten millionth programmer on our planet who is trying to invent his own bicycle. I also suffer from this sometimes. But I didn't try to write my database.
Tell P'thon (did I read your nickname correctly?), why are you writing this file at all if you are afraid to read it? Bunned usirs, is it supposed to be checked with this for almost every request? I bet you don't even know what you're getting yourself into. Try at least sqlite, it's built right into python.

A
Andrey, 2019-12-23
@anerev

In fact, python translates json into a regular dictionary, so you can add / remove using the usual dictionary methods, and then convert back to json https://python-scripts.com/json

V
Vladimir Korotenko, 2019-12-23
@firedragon

"bannedUsers" : {
  "IDS" : ["575656567","575656567"]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question