How to convert json to Python List? -


i want data in form of list while using pycurl it's showing object of json :( please tell me simplest way how break , list out of it? in advance guiding :) here code:

import pycurl  import json   io import bytesio   c = pycurl.curl() data = bytesio()  c.setopt(c.url,'https://api.angel.co/1/jobs') c.setopt(c.writefunction, data.write)  c.perform() fetched_data= data.getvalue() print (fetched_data);  

decode json json module imported:

result = json.loads(fetched_data.decode('utf8')) 

i hardcoded encoding here; json rfc states utf-8 default, see if content-type response header has charset parameter tells actual encoding.

i'd not use pycurl; really, cumbersome deal with. use requests library instead, can handle json you, out of box. handles decoding of bytestream unicode for you:

import requests  result = requests.get('https://api.angel.co/1/jobs').json() 

that specific url returns json object, resulting in python dictionary:

{'jobs': [{'angellist_url': 'https://angel.co/jobs?startup_id=267120',             'created_at': '2014-02-06t08:07:35z',             'equity_cliff': '0.0',             'equity_max': '0.0',             'equity_min': '0.0',             'equity_vest': '0.0',             'id': 22672,             'salary_max': 0,             'salary_min': 0,             'startup': {'angellist_url': 'https://angel.co/nationsroot-1',                          'community_profile': false,                          'company_url': 'http://nationsroot.com',                          'created_at': '2013-09-20t07:55:25z',                          'follower_count': 5,                          'hidden': false,                          'high_concept': 'bridge between citizens , politicians',                          'id': 267120,                          'logo_url': 'https://s3.amazonaws.com/photos.angel.co/startups/i/267120-9513670dbfe74c170201df0e385d1c2c-medium_jpg.jpg?buster=1379663721',                          'name': 'nationsroot',                          'product_desc': 'nationsroot helps find profiles , report cards of politicians, share thoughts , rate political leaders. believe citizens not absolved of duties once done voting. so, provide platform can rate quality of government provided services create real time report cards politicians.\r\n\r\non other hand, politicians have detail analytics requirements of citizens in various electoral area helpful during elections , can have latest updates too.',                          'quality': 3,                          'thumb_url': 'https://s3.amazonaws.com/photos.angel.co/startups/i/267120-9513670dbfe74c170201df0e385d1c2c-thumb_jpg.jpg?buster=1379663721',                          'updated_at': '2014-02-06t07:36:36z'},             'tags': [{'angellist_url': 'https://angel.co/business-development-1',                        'display_name': 'business development',                        'id': 15525,                        'name': 'business development',                        'tag_type': 'skilltag'},                       {'angellist_url': 'https://angel.co/sales-strategy-and-management',                        'display_name': 'sales strategy , management',                        'id': 16928,                        'name': 'sales strategy , management',                        'tag_type': 'skilltag'},                       {'angellist_url': 'https://angel.co/sales-and-marketing-2',                        'display_name': 'sales , marketing',                        'id': 23989,                        'name': 'sales , marketing',                        'tag_type': 'skilltag'},                       {'angellist_url': 'https://angel.co/australia',                        'display_name': 'australia',                        'id': 1618,                        'name': 'australia',                        'tag_type': 'locationtag'},                       {'angellist_url': 'https://angel.co/sales-2',                        'display_name': 'sales',                        'id': 80488,                        'name': 'sales',                        'tag_type': 'roletag'}],             'title': 'sales intern',             'updated_at': '2014-02-06t08:07:57z'},            # many more entries elided            ],  'last_page': 184,  'page': 1,  'per_page': 50,  'total': 9195} 

the list looking result['jobs'], you'll have request additional pages 9195 results.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -