I am new at pymongo, but have a decent knowledge on mongoDB So basically I have a list of strings, then I converted it into a dictionary using key as integer, so as pymongo doesn't allow integer keys, I converted that dictionary to json using json.dumps() and then tried inserting into the DB. But its showing this error : TypeError: document must be an instance of dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a type that inherits from collections.MutableMapping
Sample code:
list = ["string1", "string2", "string3"]
dict1 = {}
for i in range(0, len(list)):
dict1[i] = list[i]
json1 = json.dumps(dict1)
connection = MongoClient("mongodb://localhost:27017/")
db = connection["test"]
collection1 = db["test"]
collection1.insert_one(json1)