2016-04-28 22 views
0

私は最近JSONの作業を開始しました。下のコードは私が働いているもののスニペットを示しています。この例では、集合{1411、1410、2009、3089}を抽出したいと考えています。 JSONはこのためのメソッドを提供するのですか、それとも自分で作成する必要がありますか?セット内のすべてのアイデンティティを一覧表示するJSON

関連がある場合は、私は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は単なるデータ形式であり、ライブラリではありません。それを処理するために使用している言語は常に*関連しています。 – chepner

+1

それを辞書に読み込んでキー()を呼び出すことはできませんか? – JETM

答えて

0

他にも述べたように、JSONはフォーマットであり、APIを提供しません。あなたはPythonを使っているので、できることは

import json 
my_data = json.loads(my_json) 
print my_data.keys() 

あなたのIDはキーと同じであると仮定します。また、キーが一意であるため、setを実行する必要はありません。

1

いいえ、JSONでは、そのメソッドまたはすべてのメソッドのメソッドをまったく提供していません。 JSONはデータを表現するための単なるフォーマットに過ぎません。

関連する問題