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

pjson not returning expected value with Swift #227

Open
dlo opened this issue Jan 30, 2018 · 10 comments
Open

pjson not returning expected value with Swift #227

dlo opened this issue Jan 30, 2018 · 10 comments

Comments

@dlo
Copy link

dlo commented Jan 30, 2018

Using the latest version of chisel from Homebrew. When I use pjson on a [String: String] dictionary in Swift, it doesn't appear to work.

(lldb) pjson response 
error: error: use of undeclared identifier 'response'
error: error: use of undeclared identifier 'None'
None

Happy to help contribute a fix if this only works for Objective-C!

@kastiglione
Copy link
Contributor

Does this work?

pjson `response`

@kastiglione
Copy link
Contributor

I think this problem can be resolved by #228. If you'd like to try this on your machine, I can help you with that.

@dlo
Copy link
Author

dlo commented Jan 31, 2018

@kastiglione I'm going to check this out tomorrow morning. Thanks again for the quick change! You are awesome!

@dlo
Copy link
Author

dlo commented Jan 31, 2018

@kastiglione Finally got around to testing master. :)

Here's the output I get with the latest change in #228:

(lldb) pjson `response`
error: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x7f9dd97dde90).
The process has been returned to the state before expression evaluation.
error: error: use of undeclared identifier 'None'
None

It's weird that I see an EXC_BAD_ACCESS, since po response works as expected.

@dlo
Copy link
Author

dlo commented Jan 31, 2018

FWIW, here's my pjson function in my existing .lldbinit. This one works as expected:

command regex ppjson 's/(.+)/po print(NSString(data: JSONSerialization.data(withJSONObject: %1, options: .prettyPrinted), encoding: String.Encoding.utf8.rawValue))/'

@kastiglione
Copy link
Contributor

Do the changes in #228 work without the backticks?

pjson response

The backticks was a workaround suggestion to try, but then I opened the pull request which I expected would fix the bug.

@dlo
Copy link
Author

dlo commented Jan 31, 2018 via email

@kastiglione
Copy link
Contributor

I think there are two problems here. One is fixed by #228, but the other is a need to handle swift array/dictionary types. Either by adding some bridging casts, or as how you've done in the alias, by avoiding objc entirely and doing the conversion in swift. I'll have to try them and report back.

@dlo
Copy link
Author

dlo commented Feb 2, 2018

Sounds great, let me know if you'd like an extra hand.

@edwardIshaq
Copy link

edwardIshaq commented Oct 26, 2018

This worked for me:

pjson json as NSDictionary
(There is a ` surrounding the json as NSDictionary part)

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

3 participants