You are ignoring the return value of json.loads() here:
json.loads(r.data.decode('utf-8'))
You then try to decode the same raw again and try to use that as the decoded Python result. Call json.loads() once, and use the resulting Python dictionary:
result = json.loads(r.data.decode('utf-8'))
start = result['data'][0]['start_time_delta']
end = result['data'][0]['end_time_delta']
Because top-level dictionary 'data' key points to a list of results, I used 0 to get to the first of those and extract the data you want.
If you need to extract those data points for every dictionary in that list, you'd have to use a loop:
for entry in result['data']:
start = entry['start_time_delta']
end = entry['end_time_delta']
# do something with these two values, before iterating to the next
Answer from Martijn Pieters on Stack OverflowPython
docs.python.org › 3 › library › json.html
json — JSON encoder and decoder
2 weeks ago - Return the Python representation of s (a str instance containing a JSON document). JSONDecodeError will be raised if the given JSON document is not valid. ... Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended.
json.decoder.JSONDecodeError: Extra data ||| While trying to read .json file
Well, your file, technically, isn't a valid JSON. But it is many JSON fragments strung together. If you have no control over the format this is written, then you could extract the position information from the error you are getting and use it to slice the string you are parsing in such a way that you only read a fragment at a time. This means that you will parse every piece of JSON twice, but, hopefully, this is a small price to pay. If this needs to be fast... then, write your own parser, in C or something that can be made fast... More on reddit.com
How Do I Decode a JSON Within a JSON un Lambda Python?
Something like import json json.loads(event["Records"][0]["Sns"]["Message"]) should give you the decoded Python dict like your first event. Of course, you might want to do this for each record, not just the first element in the list, so: s3_events = [json.loads(record["Sns"]["Message"]) for record in event["Records"]] should do the trick. More on reddit.com
Why we can't lazy-decode JSON
There's a JSON "parser" called jsmn that parsers JSON very fast. Well, I say "parse", but it's basically just tokenization. Fields aren't actually decoded, objects and arrays aren't built into native objects. What you get is an array of token objects with annotations. With a little modification you can get something that you can do O(N) structured lookups on, "half-lazily." More on reddit.com
How to fix JSONDecodeError when parsing JSON files?
It's difficult to give you a directly solution since we don't know what var_JSON.text looks like. As a side note, you can use request's .json() method to directly parse the json object into a dictionary. var_JSON = requests.get(var_url).json() More on reddit.com
Videos
03:06
Working with JSON in Python: Encoding and Decoding - YouTube
14:27
Python JSON Parsing: A Step-by-Step Guide to Extract Data from ...
03:30
How to Work with JSON Data in Python | Parse, Read & Write JSON ...
12:57
Python Modules #4: json - JSON Encoder and Decoder. Working with ...
06:32
JSON Python tutorial: what is JSON and how to parse JSON data with ...
19:29
8.8 - Learn Python: Custom Encoding and Decoding with JSON - YouTube
Reddit
reddit.com › r/python › handling json files with ease in python
r/Python on Reddit: Handling JSON files with ease in Python
May 29, 2022 -
I have finished writing the third article in the Data Engineering with Python series. This is about working with JSON data in Python. I have tried to cover every necessary use case. If you have any other suggestions, let me know.
Working with JSON in Python
Data Engineering with Python series
W3Schools
w3schools.com › python › python_json.asp
Python JSON
If you have a JSON string, you can parse it by using the json.loads() method. The result will be a Python dictionary.
ScrapingBee
scrapingbee.com › blog › how-to-read-and-parse-json-data-with-python
How to read and parse JSON data with Python | ScrapingBee
January 17, 2026 - In this article, you learned how to encode and decode a JSON string to a Python object and vice versa. Moreover, you saw how a custom encoder can be used to encode custom types to JSON. The json package is very versatile and provides a ton of additional features that are worth exploring.
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
Claudia Kuenzler
claudiokuenzler.com › blog › 1394 › how-to-handle-json-decode-error-python-script-try-except
How to handle JSON decode error in Python script with try and except
February 20, 2024 - However the error handler JSONDecodeError does not exist in the "global" namespace of the Python script and needs to be called from the json module: try: data = json.loads(output) except json.JSONDecodeError as e: print("Error: Unable to decode JSON, Error: {}. Manually run command ({}) to verify JSON output.".format(e, cmd))
QuickType
quicktype.io
Convert JSON to Swift, C#, TypeScript, Objective-C, Go, Java, C++ and more
quicktype generates types and helper code for reading JSON in C#, Swift, JavaScript, Flow, Python, TypeScript, Go, Rust, Objective-C, Kotlin, C++ and more. Customize online with advanced options, or download a command-line tool.
GeeksforGeeks
geeksforgeeks.org › python › python-jsondecoder-module
Python json.decoder Module - GeeksforGeeks
July 23, 2025 - Sometimes, you might want to convert JSON keys and values into specific Python objects based on their data types or values. JSONDecoder can be customized by overriding the default object_hook. This is a function that takes a dictionary and returns a dictionary. You can define your own conversions within this function. ... import json from datetime import datetime def custom_decoder(dict_data): if 'date' in dict_data: dict_data['date'] = datetime.strptime(dict_data['date'], '%Y-%m-%d') return dict_data json_data = '{"name": "Alice", "date": "2021-08-01"}' decoder = json.JSONDecoder(object_hook=custom_decoder) data = decoder.decode(json_data) print(data)
W3Schools
w3schools.com › python › gloss_python_json_parse.asp
Python JSON Parse
The result will be a Python dictionary. ... import json # some JSON: x = '{ "name":"John", "age":30, "city":"New York"}' # parse x: y = json.loads(x) # the result is a Python dictionary: print(y["age"]) Try it Yourself »
Real Python
realpython.com › python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - That means you can conveniently convert Python data types into JSON data and the other way around. The act of converting data into the JSON format is referred to as serialization. This process involves transforming data into a series of bytes for storage or transmission over a network. The opposite process, deserialization, involves decoding data from the JSON format back into a usable form within Python.
Inductive Automation
docs.inductiveautomation.com › appendix › scripting functions › system.util › system.util.jsondecode
system.util.jsonDecode | Ignition User Manual
April 4, 2024 - # The following example reads in a JSON string, and converts the string to a Python object. # The example attempts to read the JSON string from a text file, but this could easily be modified to read data from a web server. # Read the JSON string jsonString = system.file.readFileAsString("C:\tmp\\json.txt") # Decode the JSON string and store the results into a variable obj = system.util.jsonDecode(jsonString) # Do something with the results.
ReqBin
reqbin.com › code › python › g4nr6w3u › python-parse-json-example
How to parse a JSON with Python?
Python has a built-in module called ... JSON Encoder and Decoder module, you can serialize (dump) Python objects to JSON strings or deserialize (parse) JSON strings to Python objects....