Answer the question
In order to leave comments, you need to log in
How to select data?
How to form a new one from the original json, which should include only some fields by several keys?
Answer the question
In order to leave comments, you need to log in
import json
j = """{
"firstName": "Иван",
"lastName": "Иванов",
"address": {
"streetAddress": "Московское ш., 101, кв.101",
"city": "Ленинград",
"postalCode": 101101
},
"phoneNumbers": [
"812 123-1234",
"916 123-4567"
]
}"""
# Превращайте исходный json в питоновский словарь:
d = json.loads(j)
# Удаляйте ненужное
del d["address"]
del d["phoneNumbers"]
# Превращайте словарь в json
s = json.dumps(d)
# ??? PROFIT!
print s
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question