N
N
noob2222019-10-22 21:01:36
Python
noob222, 2019-10-22 21:01:36

How to remove json from python?

Hello, I decided to learn how to work with json in python and there was a problem when I save data in json, then how to delete this data if I have not one value but many stored in this json dictionary?
This is what the json file looks like when I save the data there
[
{
"user_id": 1,
"first_name": "Elova",
"last_name": "Elizaveta"
},
{
"user_id": 2,
"first_name": "Alex",
"last_name": "Petrov"
}
]
how can I delete the json data of the second object only?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-10-22
@noob222

In general, in python there is del

data = [
{
"user_id": 1,
"first_name": "Elova",
"last_name": "Elizaveta"
},
{
"user_id": 2,
"first_name": "Alex",
"last_name": "Petrov"
}
]
del data[1]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question