Ich habe eine JSON mit folgenden Struktur:Schleife durch mehrdimensionale JSON (Python)
{
'count': 93,
'apps' : [
{
'last_modified_at': '2016-10-21T12:20:26Z',
'frequency_caps': [],
'ios': {
'enabled': True,
'push_enabled': False,
'app_store_id': 'bbb',
'connection_type': 'certificate',
'sdk_api_secret': '--'
},
'organization_id': '--',
'name': '---',
'app_id': 27,
'control_group_percentage': 0,
'created_by': {
'user_id': 'abc',
'user_name': 'def'
},
'created_at': '2016-09-28T11:41:24Z',
'web': {}
}, {
'last_modified_at': '2016-10-12T08:58:57Z',
'frequency_caps': [],
'ios': {
'enabled': True,
'push_enabled': True,
'app_store_id': '386304604',
'connection_type': 'certificate',
'sdk_api_secret': '---',
'push_expiry': '2018-01-14T08:24:09Z'
},
'organization_id': '---',
'name': '---',
'app_id': 87,
'control_group_percentage': 0,
'created_by': {
'user_id': '----',
'user_name': '---'
},
'created_at': '2016-10-12T08:58:57Z',
'web': {}
}
]
}
Es ist ein JSON mit zwei Schlüsseln-Wert-Paaren. Der Wert des zweiten Paares ist eine Liste von mehr JSONs. Für mich ist es zu viel Information, und ich möchte ein JSON wie diese haben:
{
'apps' : [
{
'name': 'Appname',
'app_id' : 1234,
'organization_id' : 'Blablabla'
},
{
'name': 'Appname2',
'app_id' : 5678,
'organization_id' : 'Some other Organization'
}
]
}
Ich möchte ein JSON haben, die einen Schlüssel („Apps“) und sein Wert nur enthält, die eine Liste wäre von mehr JSONs, die nur drei Schlüssel-Wert-Paare haben. Ich bin dankbar für jeden Rat.
Vielen Dank für Ihre Hilfe!
Dies sollte ziemlich einfach sein zu erreichen, haben Sie etwas versuchen, so weit? – errata
Sorry, ich bin absolut neu in StackOverflow ... Ja, ich habe versucht, eine for-Schleife, die funktionierte, aber es fühlte sich falsch .. –