Фильтрация блоков JSON в python
Задача отбросить лишние блоки из JSON в название которых начинается с spring* или managment* Изначально приходит :
{
"spring.jpa......": {
"name": "Ford Prefect",
"species": "Betelgeusian",
"relatives": [
{
"name": "Zaphod Beeblebrox",
"species": "Betelgeusian"
}
]
}
"managment.endpoint......": {
"name": "Ford Prefect",
"species": "Betelgeusian",
"relatives": [
{
"name": "Zaphod Beeblebrox",
"species": "Betelgeusian"
}
]
}
"searchPropirties.....": {
"name": "Ford Prefect",
"species": "Betelgeusian",
"relatives": [
{
"name": "Zaphod Beeblebrox",
"species": "Betelgeusian"
}
]
}
}
И таких блоков может быть много. после обработки должен остаться только:
{
"searchPropirties.....": {
"name": "Ford Prefect",
"species": "Betelgeusian",
"relatives": [
{
"name": "Zaphod Beeblebrox",
"species": "Betelgeusian"
}
]
}
}
Возможно ли это сделать на Python для такого запроса?
curl <ip>/actuator/configprops |
python -c "import sys, json, re; \
obj = json.load(sys.stdin)['contexts']['search']['beans']; \
print json.dumps(obj);" |
python -m json.tool | less