This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks ChatGPT! | |
// Getting back a Python dictionary in JavaScript, and need it to be JSON | |
function pythonDictToJson(pythonDictString) { | |
// Regular expression to match and replace Python literals | |
const regex = /('(\\'|[^'])*')|None|True|False/g; | |
// Replacer function to handle each match | |
const replacer = (match) => { | |
if (match === 'None') { | |
return 'null'; |
OlderNewer