'Is there a way to get double quotes in json.loads method

I need to prepare input data for a API in json format.

I am using json.loads() function but it is returning data with single quotes. I have tried to convert data into strings and added double quotes but that does not help.

import json
import pandas as pd


data = pd.read_csv('..\\dummy_api_data.csv')

dict_data = data.to_dict(orient='records')
data_json_dump = json.dumps(dict_data, default='str')

json_data = json.loads(data_json_dump)

Output :- {'name': 'Shawna', 'age': 46, 'salary': 119090}

Expected Output:- {"name": "Shawna", "age": 46, "salary": 119090}



Solution 1:[1]

Have you tried adding the content-type json to your header

headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Muna Bedan