Created
May 23, 2018 09:42
-
-
Save asvetlov/fd3213720b03a144e0e1465ea02064cf to your computer and use it in GitHub Desktop.
This file contains 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
import json | |
import re | |
s = """new APIData([ | |
new APIControllers([ | |
new APIProp({name:"durable-id",value:"controller_a"}), | |
new APIProp({name:"controller-id",value:"A"}), | |
new APIProp({name:"controller-id-numeric",value:"1"}), | |
new APIProp({name:"serial-number",value:"CN8415M489"}) | |
]) | |
])""" | |
s2 = re.sub("new API[A-Za-z]+", "", s) | |
s3 = s2.replace('(', '') | |
s4 = s3.replace(')', '') | |
s5 = re.sub("([a-z]+):", r'"\1":', s4) | |
ret = json.loads(s5) | |
print(ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment