mirror of
https://github.com/foss42/apidash.git
synced 2025-05-23 09:17:04 +08:00
Update Python requests codegen
This commit is contained in:
15
lib/codegen/codegen_utils.dart
Normal file
15
lib/codegen/codegen_utils.dart
Normal file
@ -0,0 +1,15 @@
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user