JSON File: http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json I'm using Python 2.
I am trying to extract all the 'paper_item_id' 's from the JSON file (specified above), using a loop and storing the 'paper_item_id' in a 'item_id' variable, so this variable will change each time the loop iterates to the 'paper_item_id', but also I want to have an if statement which checks if the 'paper_item_id' in the JSON file 'is_bait' is 'true' if it is true the the 'item_id' variable will not store the 'paper_item_id' which has an 'is_bait' of true and go on to the next one.
Step 1) Get JSON Data.
Step 2) Filter out 'paper_item_id' 's with the 'is_bait' to true.
Step 3) Run a loop which assigns a 'item_id' variable to the 'paper_item_id' received.
Step 4) The loop should run so all filtered 'paper_item_id' (item_id) has been passed to 'myFunction'
Sample English Like Code:
foreach ('don't know what to have for the loop cond') {
item_id = 'paper_item_id'
if (item_id[is_bait]) == true {
code which will go to the end of the loop
}
else
{
myFunction(item_id)
}
I know this has a Javascript kind-of syntax but I want it in python.
What I have now:
import json
import urllib2
url = 'http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json'
result = json.loads(url)
request = urllib2.Request(url)
response = urllib2.urlopen(request)
json_obj = json.load(response)
What do I do know?