-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonpy.py
38 lines (34 loc) · 1.13 KB
/
jsonpy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
def pywrite(jsonpy):
# test = {"def fun():": {"value": "1", "print(": "'test',value)"}}
with open("dynampy.py", "w", encoding="utf-8") as f:
json.dump(jsonpy, f, ensure_ascii=False, indent=4)
pyjson = ""
with open("dynampy.py", "r", encoding="utf-8") as f:
content = f.read()
# print(content)
pyjson = (
content.replace('= ": {', '= ":#~')
.replace("{", "")
.replace("}", "")
.replace(" ", "\t")
.replace(" ", "~")
.replace("\t~", "\t\t")
.replace("~", "")
.replace('(":', "(")
.replace(':":', "@")
.replace(":", "")
.replace("@", ":")
.replace("#/#", "@")
.replace('"', "")
.replace("'", '"')
.replace(",\n", "\n")
.replace(";", ",")
.replace("#~", "{")
.replace("~#", "}")
)
# print(pyjson)
with open("dynampy.py", "w", encoding="utf-8") as f:
f.write(pyjson)
import dynampy
return dynampy.run()