I'm searching for a method to escape all characters in all JSON-Keys in a JSON string that are not accepted by MongoDB (for example a . (dot)).
{"www.example.com":true}
Should become this (or any other accepted character):
{"wwwexamplecom":true}
I've done this several times before with JavaScript. But it's my first time in python and I wonder if there is a function or library for that task? I looked through the JSON chapter of the python documentation (https://docs.python.org/2/library/json.html#) but did not find a solution to this.
Maybe someone knows the answer?
Many thanks in advance,
Daniel
Edit: I think it's more a duplicate of what @alecxe write in his answer.
Edit 2: Maybe this threat is also related How can I edit/rename keys during json.load in python?