-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpj.py
36 lines (28 loc) · 979 Bytes
/
pj.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
#!/usr/bin/python
import fbchisellldbbase as fb
def lldbcommands():
return [ PrintDataAsJSONString() ]
class PrintDataAsJSONString(fb.FBCommand):
def name(self):
return "pj"
def description(self):
return "Print JSON representation of Swift Data"
def args(self):
return [
fb.FBCommandArgument(
arg="data",
type="Data",
help="Data that will be evaluated when deserializing.",
)
]
def run(self, arguments, options):
# Convert to NSObject first to allow for objc runtime to process it
objectToPrint = fb.evaluateInputExpression(
"{obj} as NSObject".format(obj=arguments[0])
)
jsonString = fb.evaluateExpressionValue(
"(NSString*)[[NSString alloc] initWithData:(NSObject*){} encoding:4]".format(
objectToPrint
)
).GetObjectDescription()
print(jsonString)