๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - When you run json.tool only with an infile option, then Python validates the JSON file and outputs the JSON fileโ€™s content in the terminal if the JSON is valid. Running json.tool in the example above means that dog_friend.json contains valid JSON syntax.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder
3 weeks ago - object_hook (callable | None) โ€“ If set, a function that is called with the result of any JSON object literal decoded (a dict). The return value of this function will be used instead of the dict.
Discussions

Handling JSON files with ease in Python
Looks good. Considered discussing dataclasses/pydantic with json? I found that these go well together More on reddit.com
๐ŸŒ r/Python
55
421
May 29, 2022
How would you use python to create JSON files?
I read two concrete questions from your post: why you would want to create a JSON object Imagine you want multiple software systems to communicate. Let's say we have three systems, one written in Python, one client written in JavaScript and one more backend system in Java. You can't just send Python objects over a network and expect the systems written in JS or Java to understand them. Same thing the other way around. In the end it's just electrical signals and both the sender and receiver need a common understanding of how to interpret those signals, otherwise they will just be gibberish. That's where data formats like JSON come into play: It's a simple and standardized data format that can be handled in any modern programming language. Now your Python code can serialize its internal representation of a piece of data into this format and send it over a network or store it on some disk, where some other system will eventually pick it up, deserialize it into its own internal representation and process it. show how you would create a JSON object with python import json data = {"year": 2020, "sales": 12345678, "currency": "โ‚ฌ"} # creating a JSON string json_string = json.dumps(data) # storing it in a file with open("data.json", "w") as json_file: json.dump(data, json_file) More on reddit.com
๐ŸŒ r/learnpython
7
5
March 7, 2020
Really struggling with parsing json and dictionaries
I have a feeling you're overthinking this. When you access a value using jq, you look through each level and determine which element you need from the next level. Sometimes, the item is an array, so you access it via its index; sometimes, it's an object, so you access it via its dictionary. Really it's exactly the same with Python, except you would be more explicit with the lookups. In this case, assuming you do only have one Vpc as shown in that JSON, you don't need any loops at all; you can just access it directly: cidr_block = vpc['Vpcs'][0]['CidrBlock'] The outer data structure is a dict, so access it via keys; its Vpc key contains a list, so access that via index; the only item in the list is a dict, so access it via the key you want. The reason why your loop gets the cidr and then fails is because it looks through every key in the outer dictionary; the first one is Vpc, so it works, but the second one is ResponseMetadata whose value is a dict, not a list, so you get the error as you're trying to index it like a list. And no, you don't need to dump it back to JSON; I'm not sure why you think you need to. JSON is a string format, which you can use to send data to and from an API, but you would only ever interact with that data in Python format. More on reddit.com
๐ŸŒ r/learnpython
16
3
June 15, 2022
Working with JSON in Python
Nice article. One minor, super-pedantic nit-pick: you keep using the words "JSON object", when you don't really mean that. A "JSON object" is merely one particular type a JSON string or text can hold, as defined by RFC7159 and its update RFC8259 , ECMA262 , ECMA404 , W3C, and various other standards. So you keep describing how to convert to/from "JSON object", when what you're really doing is converting to/from JSON string (which are also python strings) - and those strings actually are of JSON arrays in your examples, not JSON objects. The arrays happen to contain JSON objects inside the array. So for example this: json.dumps() takes in a Python data type and returns a JSON object. json.loads() takes in a JSON object and returns a Python data type. ...isn't actually true. For example just the two characters 42 is a perfectly valid JSON string, of just a JSON number type. Python's json.dumps() will accept a python int of 42 and convert it to a string. It will then take that serialized python/JSON string and convert it back to a simple python int, using json.loads(). There is no JSON object involved whatsoever. Again, I know I'm being pedantic. And I don't mean to criticize - the article's fine overall. I just get triggered by some minor details sometimes. :) More on reddit.com
๐ŸŒ r/Python
5
2
April 13, 2022
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_json.asp
Python JSON
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... JSON is a syntax for storing and exchanging data.
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - In Python, the json.dumps() function provides options for formatting and ordering the JSON output. Here are some common options: This option specifies the number of spaces to use for indentation in the output JSON string. For example:
๐ŸŒ
Code Institute
codeinstitute.net โ€บ blog โ€บ python โ€บ working with json in python: a beginnerโ€™s guide
Working with JSON in Python: A Beginner's Guide - Code Institute NL
February 6, 2024 - In this example, the JSON data will be written to โ€˜person_indented.jsonโ€™ with an indentation of 4 spaces, making it more readable. Python also provides a command-line tool for working with JSON, called `json.tool`. This tool is useful for formatting JSON data directly from the command line.
๐ŸŒ
The Hitchhiker's Guide to Python
docs.python-guide.org โ€บ scenarios โ€บ json
JSON โ€” The Hitchhiker's Guide to Python
d = { 'first_name': 'Guido', 'second_name': 'Rossum', 'titles': ['BDFL', 'Developer'], } print(json.dumps(d)) '{"first_name": "Guido", "last_name": "Rossum", "titles": ["BDFL", "Developer"]}'
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_format_json.asp
Python Format JSON
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... The example above prints a JSON string, but it is not very easy to read, with no indentations and line breaks.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-json
Python JSON - GeeksforGeeks
April 23, 2025 - This is JSON <class 'str'> Now convert from JSON to Python Converted to Python <class 'dict'> {'id': '09', 'name': 'Nitin', 'department': 'Finance'} Let's see a simple example where we convert Python objects to JSON objects.
Find elsewhere
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-parse-json-in-python-with-examples
How to Parse JSON in Python โ€“ A Complete Guide With Examples
October 29, 2025 - After the with block completes, you have a Python dictionary containing all the parsed configuration data. API URL: https://api.example.com/v2 Timeout: 30 seconds Logging: Enabled ยท JSON parsing can fail for many reasons: malformed syntax, unexpected data types, corrupted files, or network issues when fetching from APIs.
๐ŸŒ
Zyte
zyte.com โ€บ home โ€บ blog โ€บ json parsing with python [practical guide]
A Practical Guide to JSON Parsing with Python
July 6, 2023 - However, while the basic principles of object-oriented programing are the same across different programming languages, the syntax, features, and use cases of custom objects can vary depending on the language. Custom Python objects are typically created using classes, which can encapsulate data and behavior. One example of a custom Python object is the Car class: ... This error occurs because json.dumps() doesn't know how to serialize our Car object.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ json
Python JSON: Read, Write, Parse JSON (With Examples)
In this tutorial, you will learn to parse, read and write JSON in Python with the help of examples. Also, you will learn to convert JSON to dict and pretty print it.
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ json
Python JSON: Syntax, Usage, and Examples
If you call an API and get back a JSON string, you convert it into Python data so you can use it. A typical API response might include user info, product lists, or search results. JSON is popular for config files because itโ€™s readable and easy to edit. You can store settings like: ... If your script needs to save progress, JSON can be a quick solution. For example:
๐ŸŒ
Python Cheatsheet
pythoncheatsheet.org โ€บ home โ€บ modules โ€บ json module
Python JSON Module - Python Cheatsheet
import json # JSON string to parse json_person = '{"name": "Charles", "age": 33, "has_hair": false, "hobbies": ["photography", "running"]}' # Parse JSON string into Python dictionary python_person = json.loads(json_person) python_person
๐ŸŒ
W3Resource
w3resource.com โ€บ JSON โ€บ snippets โ€บ json-example-guide.php
JSON Examples and Implementation Explained
import json # Import the JSON module # Example JSON data json_data = '''{ "name": "Catrinel", "age": 25, "skills": ["JavaScript", "Python", "SQL"], "address": { "city": "New York", "zip": "10001" }, "isEmployed": true }''' # Parsing JSON into ...
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ working-with-json-data
Working with JSON data - Python Morsels
November 20, 2023 - And if you need to serialize dictionaries, lists, numbers, booleans, strings, and None values into JSON data, you can use the dumps function from Python's json module. ... We don't learn by reading or watching. We learn by doing. That means writing Python code.
๐ŸŒ
Medium
medium.com โ€บ data-science โ€บ working-with-json-data-in-python-45e25ff958ce
JSON in Python Tutorial | TDS Archive
August 11, 2021 - Writing to json files, reading from json files explained and illustrated with examples in python.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_json_syntax.asp
JSON Syntax
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_json.htm
Python - JSON
encode(obj) โˆ’ Serializes a Python object into a JSON formatted string. iterencode(obj) โˆ’ Encodes the object and returns an iterator that yields the encoded form of each item in the object. indent โˆ’ Determines the indent level of the encoded ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-use-the-json-module-in-python
How to Use the JSON Module in Python โ€“ A Beginner's Guide
June 5, 2023 - As you can see in the example, executing the json.tool module with the input file path formats the JSON data and displays the formatted output on the console. You can also redirect the formatted output to an output file by specifying the output file name as the second argument: python -m json.tool horoscope_data.json formatted_data.json
๐ŸŒ
Bobdc
bobdc.com โ€บ blog โ€บ pythonjson
Parsing JSON with Python
December 15, 2024 - My sample demo data to parse is pretty close to the test input that I used when I wrote about JSON2RDF: { "mydata": { "color": "red", "amount": 3, "arrayTest": [ "north", "south", "east", "escaped \"test\" string", "west" ], "boolTest": true, "nullTest": null, "addressBookEntry": { "givenName": "Richard", "familyName": "Mutt", "address": { "street": "1 Main St", "city": "Springfield", "zip": "10045" } } } } ... #!/usr/bin/env python3 import json f = open('jsondemo.js') data = json.load(f) print(data["mydata"]["color"]) print(data["mydata"]["amount"]) # Pull something out of the middle of an ar