Skip to content

Implementing JSONSerialization.writeJSONObject #465

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

Merged
merged 1 commit into from
Jul 26, 2016

Conversation

saiHemak
Copy link
Contributor

No description provided.

@@ -159,7 +159,13 @@ public class JSONSerialization : NSObject {
/* Write JSON data into a stream. The stream should be opened and configured. The return value is the number of bytes written to the stream, or 0 on error. All other behavior of this method is the same as the dataWithJSONObject:options:error: method.
*/
public class func writeJSONObject(_ obj: AnyObject, toStream stream: NSOutputStream, options opt: WritingOptions) throws -> Int {
NSUnimplemented()
do {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API differs from the Darwin version,the latter takes a fourth argument of type NSErrorPointer which is a typealias unavailable on Linux .The Darwin version also does not throw any error.The spec says that 0 needs to be returned on error.If we return 0 we cannot throw the error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected this code to just call 'try' and not 'catch', therefore propagating the error outward if it happens (both from data(withJSONObject:options:) and stream.write).

@saiHemak saiHemak force-pushed the nsjsonserialization-branch branch from 2a48f42 to 16bfcf8 Compare July 26, 2016 08:41
@saiHemak
Copy link
Contributor Author

@parkera ,I have addressed your comments please review .

@parkera
Copy link
Contributor

parkera commented Jul 26, 2016

Thanks!

@parkera
Copy link
Contributor

parkera commented Jul 26, 2016

@swift-ci please test

@parkera parkera merged commit 2acafc7 into swiftlang:master Jul 26, 2016
@parkera
Copy link
Contributor

parkera commented Jul 26, 2016

Unfortunately this crossed paths with the stdlib change to rename all of the pointer types.

@parkera
Copy link
Contributor

parkera commented Jul 26, 2016

cc @atrick

@atrick
Copy link
Contributor

atrick commented Jul 26, 2016

I can checkin a quick fix if no one has claimed it.

@atrick
Copy link
Contributor

atrick commented Jul 26, 2016

commit dd9e438 (HEAD -> master, origin/master, origin/HEAD)
Author: Andrew Trick [email protected]
Date: Tue Jul 26 15:30:12 2016

Quick fix for conflicting commits.

DaveLiu888 pushed a commit to DaveLiu888/swift-corelibs-foundation that referenced this pull request Jul 28, 2016
@saiHemak saiHemak deleted the nsjsonserialization-branch branch February 28, 2017 07:02
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Oct 11, 2023
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

Successfully merging this pull request may close these issues.

3 participants