Python Json to array -


i want put json array. have 6 json links (with same size different issues)

that try:

data=('0','0') response = urllib.urlopen(url) data[0] = json.loads(response.read()) response = urllib.urlopen(url) data[1] = json.loads(response.read()) 

do have initialize 3d array? later fine if can work on result that:

result = data[0]['resu']['spc'] 

in end want build loop use dynamical json links that:

for w in range(0,len(urls)):     urls[w]['resu']['spc'] 

i suggest using requests (the current documentation so, too) can do:

import json import urllib2  urls=["http://example.com/json","https://example.com/json2"] # urls here  data=[] u in urls:     response = urllib2.urlopen(u)     data.append(json.loads(response.read())) # while works python 2, better use data.append(json.loads(response.read().decode("utf8")) 

for have find out/guess encoding of response.

with requests simpler:

import requests  urls=["http://example.com/json","https://example.com/json2"] # urls here data=[requests.get(u).json() u in urls] 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -