2016-04-28 3 views
0

Ich habe vor kurzem angefangen, mit JSON zu arbeiten. Der folgende Code zeigt einen Ausschnitt dessen, woran ich arbeite. In diesem Beispiel möchte ich die Menge {1411, 1410, 2009, 3089} extrahieren. Bietet JSON eine Methode dafür oder muss ich sie selbst erstellen?JSON, der alle Identitäten in einem Satz auflistet

Falls es relevant ist, arbeite ich mit Python.

{ 
    "1411": { 
    "id": 1411, 
    "plaintext": "Increases Attack Speed, and gives increasing power as you kill Jungle Monsters and Champions", 
    "description": "<stats>+40% Attack Speed<br>+30 Magic Damage on Hit<\/stats><br><br><unique>UNIQUE Passive - Devouring Spirit:<\/unique> Takedowns on large monsters and Champions increase the magic damage of this item by +1. Takedowns on Rift Scuttlers and Rift Herald increase the magic damage of this item by +2. Takedowns on Dragon and Baron increase the magic damage of this item by +5. At 30 Stacks, your Devourer becomes Sated, granting extra on Hit effects.", 
    "name": "Enchantment: Devourer", 
    "group": "JungleItems" 
    }, 
    "1410": { 
    "id": 1410, 
    "plaintext": "Grants Ability Power and periodically empowers your Spells", 
    "description": "<stats>+60 Ability Power<br>+7% Movement Speed<\/stats><br><br><unique>UNIQUE Passive - Echo:<\/unique> Gain charges upon moving or casting. At 100 charges, the next damaging spell hit expends all charges to deal 60 (+10% of Ability Power) bonus magic damage to up to 4 targets on hit.<br><br>This effect deals 250% damage to Large Monsters. Hitting a Large Monster with this effect will restore 18% of your missing Mana.", 
    "name": "Enchantment: Runic Echoes", 
    "group": "JungleItems" 
    }, 
    "2009": { 
    "id": 2009, 
    "description": "<consumable>Click to Consume:<\/consumable> Restores 80 Health and 50 Mana over 10 seconds.", 
    "name": "Total Biscuit of Rejuvenation" 
    }, 
    "3089": { 
    "id": 3089, 
    "plaintext": "Massively increases Ability Power", 
    "description": "<stats>+120 Ability Power <\/stats><br><br><unique>UNIQUE Passive:<\/unique> Increases Ability Power by 35%.", 
    "name": "Rabadon's Deathcap" 
    } 
+2

JSON ist nur ein Datenformat, keine Bibliothek. Die Sprache, die Sie zur Bearbeitung verwenden, ist * immer * relevant. – chepner

+1

Kannst du es nicht einfach in ein Wörterbuch einlesen und Schlüssel() anrufen? – JETM

Antwort

0

Wie von anderen erwähnt, ist JSON ein Format und bietet keine API. Da Sie Python verwenden, was Sie tun können, ist

Ich nehme an, Ihre IDs sind die gleichen wie Schlüssel. Außerdem müssen Sie set nicht tun, da Schlüssel einzigartig sind.

1

Nein, JSON bietet keine Methode für diese oder irgendwelche Methoden für irgendetwas. JSON ist nur ein Format für die Darstellung von Daten, mehr nicht.

Verwandte Themen