Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'json' command doesn't work with NSData objects #1

Open
snej opened this issue Apr 11, 2014 · 1 comment
Open

'json' command doesn't work with NSData objects #1

snej opened this issue Apr 11, 2014 · 1 comment

Comments

@snej
Copy link

snej commented Apr 11, 2014

I love the 'json' command, but most of the time I've got JSON stored in NSData objects, not NSStrings, and it barfs on those:

Traceback (most recent call last):
  File "/Users/snej/.lldb/MCSLLDBToolkit/mcslldb_helpers.py", line 61, in wrapper
    result = function(debugger, *args)
  File "/Users/snej/.lldb/MCSLLDBToolkit/mcslldb_commands.py", line 22, in json
    pretty_json_string = json_lib.dumps(json_lib.loads(json_string),
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
@narfdotpl
Copy link
Contributor

Thanks, @snej.

Supporting NSData seems reasonable, but there are two problems with it:

  1. You have to choose encoding (although I'm sure UTF8 is a pretty obvious default).
  2. LLDB doesn't have access to NSUTF8StringEncoding enum.

I added NSData support in de48a31 commit on 1-json-nsdata branch. I'm not sure whether to merge it into master just yet, but you can check this change out. Quit Xcode and run:

cd ~/.lldb/MCSLLDBToolkit
git pull
git checkout 1-json-nsdata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants