mirror of
https://github.com/foss42/apidash.git
synced 2025-05-22 08:46:33 +08:00
16 lines
429 B
Dart
16 lines
429 B
Dart
String jsonToPyDict(String jsonString) {
|
|
Map<String, String> replaceWithMap = {
|
|
"null": "None",
|
|
"true": "True",
|
|
"false": "False"
|
|
};
|
|
String pyDict = jsonString;
|
|
for (var k in replaceWithMap.keys) {
|
|
RegExp regExp = RegExp(k + r'(?=([^"]*"[^"]*")*[^"]*$)');
|
|
pyDict = pyDict.replaceAllMapped(regExp, (match) {
|
|
return replaceWithMap[match.group(0)] ?? match.group(0)!;
|
|
});
|
|
}
|
|
return pyDict;
|
|
}
|