I have the following json object I am trying to parse with python 3:
customerData = {   
 "Joe": {"visits": 1},  
 "Carol":  {"visits": 2},  
 "Howard": {"visits": 3},  
 "Carrie": {"visits": 4}  
}
I am using the following python code to parse the object:
import json 
def greetCustomer(customerData):
    response = json.loads(customerData)
I'm getting the following error:
TypeError: the JSON object must be str, bytes or bytearray, not 'dict'
You seem to be mistaking load and dump.
json.loads converts a string to a python object, json.load converts a json file into a python object whereas json.dumps converts a python object to a string and json.dump writes a json string to a file from a python object
Tip: notice that loads and dumps have an s at the end, as in string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With