thwack | A tiny modern data fetching solution | HTTP Client library
kandi X-RAY | thwack Summary
kandi X-RAY | thwack Summary
A tiny modern data fetching solution
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of thwack
thwack Key Features
thwack Examples and Code Snippets
Community Discussions
Trending Discussions on thwack
QUESTION
I am new to JSON in Python (forgive me if I word something incorrectly) and I am trying to parse JSON information I get from an API. I get the API information successfully, but when I attempt to extract the information that I need (specifically the 'name' value in the variable info). I can't seem to find anything on how to access it. The code is below:
...ANSWER
Answered 2020-Apr-10 at 12:31So, there's 2 types of objects you need to be aware of.
dict: when you load JSON it's stored as a dictionary object. Dict objects let you access the values through keys, like you're doing here -> info['data']['featured']
list: print(info) is showing that 'info' is a list of things. You can tell by the square brackets [], or just by calling print(type(info))
. A list is ordered so to access the name for the first object in your list you would say info[0]['name']
.
To get all the objects in your list in a row you can use a for loop:
for x in info:
print(x['name'])
You can name 'x' whatever you want. That loop is just saying " for every object in this list, perform the following action"
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install thwack
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page