- Python Tutorial: Working with JSON Data using the json Module

Python Tutorial: Working with JSON Data using the json Module

In this Python Programming Tutorial, we will be learning how to work with JSON data. We will learn how to load JSON into Python objects from strings and how to convert Python objects into JSON strings. We will also see how to load JSON from a file and save those Python objects back to files. Let'...
In this Python Programming Tutorial, we will be learning how to work with JSON data. We will learn how to load JSON into Python objects from strings and how to convert Python objects into JSON strings. We will also see how to load JSON from a file and save those Python objects back to files. Let's get started...

The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-JSON

Python File Objects: https://youtu.be/Uh2ebFW8OYM


✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter -
Instagram - https://www.instagram.com/coreymschafer/

#Python

#json #python #python json #python json tutorial #python tutorial #json tutorial #json file #json string #python string #json parsing #parse json #json module #python json dictionary #python json example #json api #python api #json loads #json load #json dumps #json dump #python 3.6 #python 3 #python (programming language) #data #tutorial #corey schafer
@Corey Schafer nope, it’s the exact same as your script at  the only difference being instead of an underscore in the variable I just made it a capital S - Python Tutorial: Working with JSON Data using the json Module

@Corey Schafer nope, it’s the exact same as your script at the only difference being instead of an underscore in the variable I just made it a capital S

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:01:40 - 00:20:34
if someone gets an error on  use dumps instead of loads. nvm i wasnt using the ' ' ' - Python Tutorial: Working with JSON Data using the json Module

if someone gets an error on use dumps instead of loads. nvm i wasnt using the ' ' '

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:01:40 - 00:20:34
) At the  mark in your initial python code, you delete the [phone] out of the [people] array and then you stored the new version under a variable that you assign JSON.dump(data). Rather than assigning a new variable could you have just printed out the people string? Would the change have been reflective on the people string? - Python Tutorial: Working with JSON Data using the json Module

) At the mark in your initial python code, you delete the [phone] out of the [people] array and then you stored the new version under a variable that you assign JSON.dump(data). Rather than assigning a new variable could you have just printed out the people string? Would the change have been reflective on the people string?

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:05:47 - 00:19:25
at  regarding the state "objects", what is that data type? (the curly brackets, containing the key/value pairs of name / abbrev / area code) - Python Tutorial: Working with JSON Data using the json Module

at regarding the state "objects", what is that data type? (the curly brackets, containing the key/value pairs of name / abbrev / area code)

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:08:31 - 00:20:34
@ - you mention the state is still returned as a dictionary. I'm following along, but it returns my data as a string with the data being the key. Not the value. Any idea why this differs from your walkthrough? - Python Tutorial: Working with JSON Data using the json Module

@ - you mention the state is still returned as a dictionary. I'm following along, but it returns my data as a string with the data being the key. Not the value. Any idea why this differs from your walkthrough?

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:09:04 - 00:20:34
you can say đél.. - Python Tutorial: Working with JSON Data using the json Module

you can say đél..

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:09:43 - 00:20:34
at # - Python Tutorial: Working with JSON Data using the json Module

at #

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:10:50 - 00:20:34
A brief shit - Python Tutorial: Working with JSON Data using the json Module

A brief shit

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:11:16 - 00:20:34
I laughed when I heard "a brief sh*t" at  . - Python Tutorial: Working with JSON Data using the json Module

I laughed when I heard "a brief sh*t" at .

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:11:16 - 00:20:34
LMAO "Alabama, a brief shit" @ - Python Tutorial: Working with JSON Data using the json Module

LMAO "Alabama, a brief shit" @

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:11:16 - 00:20:34
LMAO "abreveshit" got me laughing by my self - Python Tutorial: Working with JSON Data using the json Module

LMAO "abreveshit" got me laughing by my self

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:11:16 - 00:20:34
a brave shit LOL - Python Tutorial: Working with JSON Data using the json Module

a brave shit LOL

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:11:16 - 00:20:34
Also, @  he said the command he'd run earlier deleted the phone number but it was the area_codes. The phone number deletion was for the people json at the beginning of the video. Not a big deal but minor errors, that can be corrected with text overlays on the video. Still, hands down, an excellent tutorial on json for beginners. - Python Tutorial: Working with JSON Data using the json Module

Also, @ he said the command he'd run earlier deleted the phone number but it was the area_codes. The phone number deletion was for the people json at the beginning of the video. Not a big deal but minor errors, that can be corrected with text overlays on the video. Still, hands down, an excellent tutorial on json for beginners.

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:11:19 - 00:20:34
the script (at ) seems to get stuck at these lines:with urlopen("https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json") as response:source = response.read()i have tried using the debug feature in Thonny, but it just gets stuck at this statement, won't carry, and also won't offer any error mesage at all. i wondered if anyone else had had this experience?UPDATE: some while later when i looked again at the Shell output in Thonny, i saw the following errors (apologies for the length):Traceback (most recent call last):File "A:\PYTHON\Corey Schafer - YouTube\api-001.py", line 4, in <module>with urlopen("https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json") as response:File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 222, in urlopenreturn opener.open(url, data, timeout)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 531, in openresponse = meth(req, response)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 641, in http_response'http', request, response, code, msg, hdrs)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 569, in errorreturn self._call_chain(*args)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 503, in _call_chainresult = func(*args)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 649, in http_error_defaultraise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 502: Server Hangup - Python Tutorial: Working with JSON Data using the json Module

the script (at ) seems to get stuck at these lines:with urlopen("https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json") as response:source = response.read()i have tried using the debug feature in Thonny, but it just gets stuck at this statement, won't carry, and also won't offer any error mesage at all. i wondered if anyone else had had this experience?UPDATE: some while later when i looked again at the Shell output in Thonny, i saw the following errors (apologies for the length):Traceback (most recent call last):File "A:\PYTHON\Corey Schafer - YouTube\api-001.py", line 4, in <module>with urlopen("https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json") as response:File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 222, in urlopenreturn opener.open(url, data, timeout)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 531, in openresponse = meth(req, response)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 641, in http_response'http', request, response, code, msg, hdrs)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 569, in errorreturn self._call_chain(*args)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 503, in _call_chainresult = func(*args)File "C:\Users\user\AppData\Local\Programs\Thonny\lib\urllib\request.py", line 649, in http_error_defaultraise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 502: Server Hangup

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:12:47 - 00:20:34
the url doesn't work  in - Python Tutorial: Working with JSON Data using the json Module

the url doesn't work in

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:13:00 - 00:20:34
Hi Corey, Around  just when you wanna see the response request, I get a bunch of errors that I have no clue what's going on. Do you recognize what the problem might be? - Python Tutorial: Working with JSON Data using the json Module

Hi Corey, Around just when you wanna see the response request, I get a bunch of errors that I have no clue what's going on. Do you recognize what the problem might be?

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:13:07 - 00:20:34
at  can we just simply json.dumps( source )  without loading it to  python object??  since it's already at strings format before loads. - Python Tutorial: Working with JSON Data using the json Module

at can we just simply json.dumps( source ) without loading it to python object?? since it's already at strings format before loads.

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:13:32 - 00:20:34
@ ohhhhh yeah!!!! like magic - Python Tutorial: Working with JSON Data using the json Module

@ ohhhhh yeah!!!! like magic

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:17:03 - 00:20:34
Hello, Corey. Thanks for all you do. Question - you set an empty dictionary around . Is there a reason you initialized it as usd_rates = dict() instead of usd_rates = {} ? - Python Tutorial: Working with JSON Data using the json Module

Hello, Corey. Thanks for all you do. Question - you set an empty dictionary around . Is there a reason you initialized it as usd_rates = dict() instead of usd_rates = {} ?

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:17:25 - 00:20:34
However, @ Corey said, "...You could see this says that a USD is equal to about 0.8465 Euros...". It's rather the other way round as the EUR is the denominator there. Similarly, there are errors @18:55 and @19:12 while demonstrating conversion of 50 USD to Euro and Indian Rupees, respectively, instead of what it should have been, 50 Euros and 50 Indian Rupees to USD. - Python Tutorial: Working with JSON Data using the json Module

However, @ Corey said, "...You could see this says that a USD is equal to about 0.8465 Euros...". It's rather the other way round as the EUR is the denominator there. Similarly, there are errors @18:55 and @19:12 while demonstrating conversion of 50 USD to Euro and Indian Rupees, respectively, instead of what it should have been, 50 Euros and 50 Indian Rupees to USD.

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:18:17 - 00:11:19
One moment for indians at    ...........................🇮🇳;;  Love from indiaaaa - Python Tutorial: Working with JSON Data using the json Module

One moment for indians at ...........................🇮🇳;; Love from indiaaaa

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:19:03 - 00:20:34
) At the  mark you've already created an empty dictionary and you've assigned the price variable to a list in the usd_rates dictionary called name. The "USD/INR" automatically converted the currency without you actually writing a conversion formula. Is this a pre-built function of Python or was the conversion written elsewhere? - Python Tutorial: Working with JSON Data using the json Module

) At the mark you've already created an empty dictionary and you've assigned the price variable to a list in the usd_rates dictionary called name. The "USD/INR" automatically converted the currency without you actually writing a conversion formula. Is this a pre-built function of Python or was the conversion written elsewhere?

Python Tutorial: Working with JSON Data using the json Module
2017年11月21日 
00:19:25 - 00:20:34

Corey Schafer

※本サイトに掲載されているチャンネル情報や動画情報はYouTube公式のAPIを使って取得・表示しています。

Timetable

動画タイムテーブル

動画数:236件

how to override existing environment variables. (This is new to me) - Python Tutorial: Securely Manage Passwords and API Keys with DotEnv

how to override existing environment variables. (This is new to me)

Python Tutorial: Securely Manage Passwords and API Keys with DotEnv
2024年04月18日  @JorgeEscobarMX 様 
00:10:42 - 00:16:58
the future spoken is my current present. Unless I'm completely desperate, I'm not hitting reddit or google/stack overflow for most roadblocks. - How to Use ChatGPT as a Powerful Tool for Programming

the future spoken is my current present. Unless I'm completely desperate, I'm not hitting reddit or google/stack overflow for most roadblocks.

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  o k t o b e r 様 
00:12:22 - 00:31:08
Good video as always😉  I remember asking that too lol - How to Use ChatGPT as a Powerful Tool for Programming

Good video as always😉 I remember asking that too lol

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  kami 様 
00:28:19 - 00:31:08
@ - pure gold, pure gold! <3 - How to Use ChatGPT as a Powerful Tool for Programming

@ - pure gold, pure gold! <3

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  ulf gjerdingen 様 
00:28:26 - 00:31:08
You almost had me there haha! ChatGPT can be wrong but it certainly wasn't wrong about those top notch resources! I massively appreciate all the uploads and I hope they keep coming supercharged with Chat GPT. Thanks to you, sentdex, techwithtim and Dennis Ivy I now know how to properly code on python, use git for version control and build a functional website. - How to Use ChatGPT as a Powerful Tool for Programming

You almost had me there haha! ChatGPT can be wrong but it certainly wasn't wrong about those top notch resources! I massively appreciate all the uploads and I hope they keep coming supercharged with Chat GPT. Thanks to you, sentdex, techwithtim and Dennis Ivy I now know how to properly code on python, use git for version control and build a functional website.

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  Uj Vag 様 
00:28:42 - 00:31:08
and it's  am here (south east asia), and idk why I'm watching a python tutorial rather than sleeping 😂 - Python Tutorial: Simulate the Powerball Lottery Using Python

and it's am here (south east asia), and idk why I'm watching a python tutorial rather than sleeping 😂

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  X 様 
00:02:49 - 00:38:56
… nice… 😂 - Python Tutorial: Simulate the Powerball Lottery Using Python

… nice… 😂

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Bartosz Turkowyd 様 
00:04:50 - 00:38:56
I've seen every Python video you've made....   first innuendo. 😜 - Python Tutorial: Simulate the Powerball Lottery Using Python

I've seen every Python video you've made.... first innuendo. 😜

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Martin Beaudry 様 
00:04:52 - 00:38:56
Man it's  am in India I am lucky to be the first one to hear your voice god bless you brother and an awesome teacher. - Python Tutorial: Simulate the Powerball Lottery Using Python

Man it's am in India I am lucky to be the first one to hear your voice god bless you brother and an awesome teacher.

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Big Samosa 様 
00:12:15 - 00:38:56
# you can also use the built-in pprint module for pretty printing dictionaries ;) - Python Tutorial: Simulate the Powerball Lottery Using Python

# you can also use the built-in pprint module for pretty printing dictionaries ;)

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Schoenling Wunderbar 様 
00:25:00 - 00:38:56
it would be very interesting to see if there could be a step function where this algorithm can simulate the increases in jackpot winnings. It’s going to be one in 292+ million of a chance that you hit it at all much less multiple times, but the code should be interesting to see. - Python Tutorial: Simulate the Powerball Lottery Using Python

it would be very interesting to see if there could be a step function where this algorithm can simulate the increases in jackpot winnings. It’s going to be one in 292+ million of a chance that you hit it at all much less multiple times, but the code should be interesting to see.

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  20 80 様 
00:27:43 - 00:38:56
A OAuth Django video would be awesome!(Applicable to all sorts of OAuth situations, not just the YouTube API.) - Python YouTube API Tutorial: Using OAuth to Access User Accounts

A OAuth Django video would be awesome!(Applicable to all sorts of OAuth situations, not just the YouTube API.)

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:07:58 - 00:43:21
At  you move the file and see some blurred miniature version of your open folders in the dock. How did you enable that? - Python YouTube API Tutorial: Using OAuth to Access User Accounts

At you move the file and see some blurred miniature version of your open folders in the dock. How did you enable that?

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:09:58 - 00:43:21
In case you are getting Error 403 ("access_denied The developer hasn’t given you access to this app") go to the OAuth consent screen and under Test Users add your email by clicking on Add Users.  You should be able to grant access after you've added User. - Python YouTube API Tutorial: Using OAuth to Access User Accounts

In case you are getting Error 403 ("access_denied The developer hasn’t given you access to this app") go to the OAuth consent screen and under Test Users add your email by clicking on Add Users. You should be able to grant access after you've added User.

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:19:36 - 00:43:21
@corey  So why did you add the join function here, when appending the video id to the list its already a list and its working for me when I pass the vid_ids directly - Python YouTube API Tutorial: Calculating the Duration of a Playlist

@corey So why did you add the join function here, when appending the video id to the list its already a list and its working for me when I pass the vid_ids directly

Python YouTube API Tutorial: Calculating the Duration of a Playlist
2020年06月11日 
00:11:24 - 00:37:38
TypeError: expected string or bytes-like object, I am taking this error in , any idea? - Python YouTube API Tutorial: Calculating the Duration of a Playlist

TypeError: expected string or bytes-like object, I am taking this error in , any idea?

Python YouTube API Tutorial: Calculating the Duration of a Playlist
2020年06月11日 
00:18:50 - 00:37:38
(I love that "Whoops that went too well"-moment at  :D) - Python Tutorial: Real World Example - Using Patreon API and Pillow to Automate Image Creation

(I love that "Whoops that went too well"-moment at :D)

Python Tutorial: Real World Example - Using Patreon API and Pillow to Automate Image Creation
2020年05月11日 
00:35:19 - 00:52:33