Skip to content

Instantly share code, notes, and snippets.

@nolili
Forked from jparishy/.lldbinit
Last active September 17, 2015 04:38
Show Gist options
  • Save nolili/a97c329467e55c4bebab to your computer and use it in GitHub Desktop.
Save nolili/a97c329467e55c4bebab to your computer and use it in GitHub Desktop.
Print JSON from LLDB
...
command script import ~/.lldb/print_json.py
# Then restart Xcode
(lldb) pj @{ @"Hello" : @"World!" }
$1 = 0x13278bf0 {"Hello":"World!"}
(lldb)
#!/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