The Wayback Machine - https://web.archive.org/web/20200713191645/https://github.com/SwiftyJSON/SwiftyJSON/issues/912
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

Issue with docs and version 4 when converting data to JSON #912

Open
jethmalani opened this issue Nov 14, 2017 · 1 comment
Open

Issue with docs and version 4 when converting data to JSON #912

jethmalani opened this issue Nov 14, 2017 · 1 comment

Comments

@jethmalani
Copy link

@jethmalani jethmalani commented Nov 14, 2017

What did you do?

When I do this (from your docs):

guard let dataFromString = text.data(using: .utf8, allowLossyConversion: false) else {return} let json = JSON(data: dataFromString)

I get an error "Call can throw, but it is not marked with 'try' and the error is not handled"

I did this. I just want to confirm that is right. It worked for me.

guard let dataFromString = text.data(using: String.Encoding.utf8, allowLossyConversion: false) else {return} var json:JSON! do { json = try JSON(data: dataFromString) } catch { print("Error JSON: \(error)") }

Please replace this with what you did.

What did you expect to happen?

Please replace this with what you expected to happen.

What actually happened instead?

Please replace this with what happened instead.

Environment

List the software versions you're using:

  • SwiftyJSON: ?.?.?
  • Xcode Version: ?.? (????) (Open Xcode; In menubar: Xcode > About Xcode)
  • Swift Version: ?.? (Open Xcode Preferences; Components > Toolchains. If none, use Xcode Default.)

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Cocoapods: ?.?.? (Use pod --version in Terminal)
  • Carthage: ?.? (Use carthage version in Terminal)
  • Swift Package Manager ?.?.? (swiftpm-???) (Use swift build --version in Terminal)

Project that demonstrates the issue

Please link to a project we can download that reproduces the issue. Feel free
to delete this section if it's not relevant to the issue (eg - feature request).

The project should be short, self-contained, and correct example.

@wongzigii
Copy link
Member

@wongzigii wongzigii commented Nov 17, 2017

@jethmalani Hi thanks for this issue.
Yes, the readme is a bit outdated for 4.0.0. Any pull request is appreciated! 😃

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.