使用 Python 从 Json 中提取数据的问题

Question with extracting data from Json using Python

我正在为 LINE 中的朋友制作一个机器人游戏。我是一个初学者。我正在尝试调用 json 中的一个对象,其中包含一个字符串 + 整数。我环顾四周,但似乎没有什么能满足我的需要。 best/simple 解决方案是什么?

我的代码是业余的,请放过我。 :P 我正在尝试通过 Json、"Name" + "Stat" 提取 Python。 现在它只提取 "Name" 并随机 select 一个项目。有没有办法select物品+属性,显示物品并计算属性?谢谢。

Python 3:
if text == 'FIGHT':
    with open('items.json', 'r') as f:
        data = json.load(f)
        armor1 = [v for d in data['armor'] for k,v in d.items() if k == 'name']
        weapon1 = [v for d in data['weapon'] for k,v in d.items() if k == 'name']
        magic1 = [v for d in data['magic'] for k,v in d.items() if k == 'name']
        armor2 = random.choice(armor1)
        weapon2 = random.choice(weapon1)
        magic2 = random.choice(magic1)
        calc = add(int(armor2), int(weapon2), int(magic2))
        line_bot_api.reply_message(
            event.reply_token, 
                TextSendMessage('Armor = ' + (armor2)),
                TextSendMessage('Weapon = ' + (weapon2)),
                TextSendMessage('Magic = ' + (magic2)),
                TextSendMessage('You have a score of ' + str(calc) + '.'),
                TextSendMessage('Waiting for next opponent...')
        )
Json:
"armor": [
{
    "name":"Cardboard armor 10 DEF" ,
    "stats":"10" },
{
    "name":"Plastic armor 20 DEF" ,
    "stats":"20" },
{
    "name":"Rubber armor 30 DEF" ,
    "stats":"30" },
{
    "name":"Metal armor 40 DEF" ,
    "stats":"40" },
{
    "name":"Indestructable armor 50 DEF" ,
    "stats":"50" }
],

几乎尝试了所有方法后.. 解决方案是:

if text == 'FIGHT':
    with open('items.json', 'r') as f:
        data = json.load(f)
        armor2 = random.choice(data['armor'])
        weapon2 = random.choice(data['weapon'])
        magic2 = random.choice(data['magic'])
        calc = add(armor2['stats'], weapon2['stats'], magic2['stats'])
        line_bot_api.reply_message(
            event.reply_token, [
                TextSendMessage('Armor = ' + (armor2['name'])),
                TextSendMessage('Weapon = ' + (weapon2['name'])),
                TextSendMessage('Magic = ' + (magic2['name'])),                 
                TextSendMessage('Total = ' + str(calc) + '.')
            ]
        )

感谢大家,特别感谢帮助我的朋友Sae。 :)