Skip to content

Instantly share code, notes, and snippets.

@faisal-w
Created April 24, 2014 02:20
Show Gist options
  • Save faisal-w/11239298 to your computer and use it in GitHub Desktop.
Save faisal-w/11239298 to your computer and use it in GitHub Desktop.
Code how to read json file
import os
import json
json_data = open("trayek_data.json").read()
print json_data
data = json_load(json_data)
json_data = open("trayek_data.json")
data = json.load(json_data)
jsondata = json_data.read()
jsondata
json_data = open("trayek_data.json")
jsondata = json_data.read()
print jsondata
print jsondata
data = json.load(jsondata)
from pprint import pprint
with open('trayek_data.json') as data_file:
data = json.load(data_file)
pprint data
pprint(data)
with open('trayek_data.json') as data_file:
data = json.load(data_file)
pprint(data)
data["result"][0]
data
for i in range(1, data["currentPageTotal"]):
print data["result"][i]["ruteBerangkat"]
for i in range(1, data["currentPageTotal"]):
print data["result"][i]["ruteBerangkat"]
print data["result"][i]["ruteKembali"]
for i in range(1, data["currentPageTotal"]):
print data["result"][i]["ruteBerangkat"]
arrayAll = []
for i in range(1, data["currentPageTotal"]):
arrayAll.append(data["result"][i]["ruteBerangkat"])
arrayAll.append(data["result"][i]["ruteKembali"])
print arrayAll
for i in range(1,data["currentPageTotal"]):
array_ind = data["result"][i]["ruteBerangkat"]
for e in array_ind :
print e
for i in range(1,data["currentPageTotal"]):
array_temp = data["result"][i]["ruteBerangkat"]
for e in array_temp :
arrayAll.append(e)
array_temp = data["result"][i]["ruteKembali"]
for a in array_temp :
arrayAll.append(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment