@MaratGan

Как мне вывести массив в json?

Добрый день!

Подскажите как мне массив вывести в json и присвоить порядковый номер каждому "элементу" должно получиться так:

0. access.,infotainment,miscell.
1. body
2. electrics
3. engine
4. front axle, steering
5. fuel, exhaust, cooling
6. gearbox
7. pedals
8. rear axle
9. wheels, brakes

{"groups":[{"full_name":"access.,infotainment,miscell.","group_name":"0","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/0.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWXd5QmtVamFwdjJjcWtrS1M2UmJ4aFpLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"body","group_name":"8","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/8.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWWpmc01scmtKVjV4c1NzbEo0OGlCV0pLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"electrics","group_name":"9","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/9.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWUFHWmRzSGRhK3hZSy9UcXJJT0pSRTVLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"engine","group_name":"1","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/1.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWVk2OERNeFJBejJNUzNBVlpISUNoSUpLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"front axle, steering","group_name":"4","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/4.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWVZtV1NKTm9KUEZDVXZFK2cyTVFnSTVLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"fuel, exhaust, cooling","group_name":"2","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/2.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWXNnWTRtS2FaWWVDOHFYbCtnUnZERVpLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"gearbox","group_name":"3","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/3.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWVdPbG9VK0lZWHZvcGRCYm55WnFZNXBLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"pedals","group_name":"7","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/7.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWUhqaXdDZmVuaGZQZmJieWFiVTN3UFpLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"rear axle","group_name":"5","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/5.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWUlMMG5NS3o5L2c4YTczbFVKOEhwRTVLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="},{"full_name":"wheels, brakes","group_name":"6","image":["https:\/\/img.levam.ru\/images\/oem\/audi2\/groups\/6.png"],"link":"RXhxcFEwQVRDQ2dxSHlRNnBENHBLeFFsOEtKWThGc29QMVIvS0FESUlRT2pvVEtwOVo5WmppaE9DU3NoY01wWStQckZyUEh2bXJPZng3eXhzZlY2Q3BLS0g3SG14VG5xWDlydXZzSlh6UStPNWpTUE1YVVRnNG4ydFc4MG9hYiszcjdlRzZ1U0tvL0xMc1BieG02MEJ6NXRraWQ1eFRGakJHNmd1TEZpZ3d6Yy9XejkzRU8wbDJZVkh3UUpIUFpka05oSm9EbTZ0ZjRxNU4zb0ZrejBiQzZ4aSthMFJFMy8wejg2c2drVVJCUT0="}]
  • Вопрос задан
  • 79 просмотров
Решения вопроса 1
shabelski89
@shabelski89
engineer
Из Вашего примера следует, что берётся значение из "full_name".
Следовательно
d_json = {your json}
d = {i: elem['full_name'] for i, elem in enumerate(d_json['groups'])}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы