PyMongo Dynamic Fields on Update

Hi,
I have a device collection that stores dynamic fields per document

{
	"field1": "value 1",
	"field2": "value 2",
	"field3": "value 3",
	"field4": "value 4",
	"field5": "value 5",
	"field6": "value 6",
}

Using a Flask PyMongo REST server, I am updating my document by passing the JSON from the client
using update_one()

@app.put("/api/devices/<id>")
def update_devices(id):
    _json = request.json
    db.sensors.update_one({'_id': ObjectId(id)}, {"$set", _json})

    resp = jsonify({"message": "Devices updated successfully"})
    resp.status_code = 200
    return resp

But I am getting “TypeError: unhashable type: ‘dict’”

The input from the client could be different only like this,

{
	"field1": "value 1",
	"field3": "value 3",
	"field4": "value 4",
}

or could be

{
	"field2": "value 2",
	"field4": "value 4",
	"field5": "value 5",
}

Is there a way to handle dynamic field updates in PyMongo? Or could I be doing something wrong?

Sorry, made a silly mistake on this line. I put a “,” instead of “:”.
All is well now.

Thanks