cancel
Showing results for 
Search instead for 
Did you mean: 

"Help with Parsing JSON String into Python List – Getting NoneType Error"

Patel0786
Deputy Chef III
Deputy Chef III

Hi everyone, I'm working with JSON data in Python, and I need help with converting a string representation of a JSON array into a Python list. Specifically, I'm trying to parse the following input:

'[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]'

 and expected output - 

[{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]

When I run this, I get the error: "TypeError: the JSON object must be str, bytes or bytearray, not NoneType". What could be causing this, and how can I fix it?

Any help would be appreciated!

Screenshot 2025-01-28 130124.pngScreenshot 2025-01-28 130141.pngScreenshot 2025-01-28 130153.png

3 REPLIES 3

shivakumara
Executive Chef II
Executive Chef II

Hi @Patel0786 ,

Python interprets this as a list of dictionaries because single quotes are valid for dictionary keys/values in Python.

This behavior is Python's native way of understanding data formats, and Workato's Python component doesn't add any special handling.

Best Practices:
1. Use double quotes for JSON keys and values when handling string representations of JSON.
2. Use json.dumps() to serialize your Python objects into valid JSON strings when needed.
3. Test your input in a Python interpreter to confirm how it’s parsed before using it in Workato.

Here is the syntax you have to use ( Sample screenshot)
Sample code.PNG

Thanks and Regards,
Shivakumar K A

Screenshot 2025-01-30 130225.png still getting same errorScreenshot 2025-01-30 130256.png

Hi @Patel0786 ,
In the 4th line please pass the output of 3rd line ( i.e. string_data). Please try and let me know.

Thanks and Regards,
Shivakumara K