Skip to content

Tag: json

json.dumps on dictionary with bytes for keys

Trying to convert dictionary object with keys of type bytes to json using json.dumps(). Format of dictionary object is not known beforehand. Have found solution for arrays or dictionaries with byte values when using json.dumps (Convert bytes embedded in list (or dict) to str for use with json.dumps) but have …

Parse Json file in python and print response in dialogflow

I have a JSON file. I want to parse it and print the response in Dialogflow. some JSON: parse x: Answer Try this Output: South Yes Update : 1 Your json is an object. It is not array. Check this https://stackoverflow.com/a/38561016/2086966 So, you does not have to iterate with a for-loop. Just use as follows U…

Object of type datetime is not JSON serializable error

I have some issues with using a DateTime value in python. When I use session_start in the following code, I get an Object of type datetime is not JSON serializable error views.py model.py traceback I retrieve the value from a database view which is filled by other tables where the user fills in their data. Co…

How to extract json from nested column to dataframe

I’m pulling stock data from TD Ameritrade API and I want to store it in a DataFrame. From the API I get a nested JSON object and when I put it in a data frame I get 4 columns: Index, Candles, Empty, Symbol. However inside of candles is a dictionary that I want as separate columns in the dataframe (&#821…

Formatting Json for Python LocustIO

Why am I getting bad request for this post calls? It has to do with json formatting. How do I reformat the json object passed as param? I’m running a load test using LocustIO and Python. Answer json.dumps takes as input json object (lists & dictionaries) and serializes it giving a string as output. …

How to import JSON file to MongoDB using Python

I have this JSON file, currencies.json: And this connection in Python: My db name is countries_db with the currency collection. Is there a way to import the file to the db using python? Thanks for your help. Answer You can read data from file and insert it into collection using insert_one method: