Created
September 19, 2013 20:20
-
-
Save jparishy/6629273 to your computer and use it in GitHub Desktop.
Print JSON from LLDB
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
... | |
command script import ~/.lldb/print_json.py | |
# Then restart Xcode |
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
(lldb) pj @{ @"Hello" : @"World!" } | |
$1 = 0x13278bf0 {"Hello":"World!"} | |
(lldb) |
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
#!/usr/bin/env python | |
# Goes in ~/.lldb/print_json.py | |
import lldb | |
import commands | |
def print_json(debugger, command, result, internal_dict): | |
lldb.debugger.HandleCommand("po [[NSString alloc] initWithData:(id)[NSJSONSerialization dataWithJSONObject:(" + command + ") options:0 error:nil] encoding:4]") | |
def __lldb_init_module(debugger, internal_dict): | |
debugger.HandleCommand("command script add -f print_json.print_json pjson") | |
print "print_json installed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jparishy Looks great, but how would you modify the above to pretty print it?