-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
).
2a48f42
to
16bfcf8
Compare
@parkera ,I have addressed your comments please review . |
Thanks! |
@swift-ci please test |
Unfortunately this crossed paths with the stdlib change to rename all of the pointer types. |
cc @atrick |
I can checkin a quick fix if no one has claimed it. |
commit dd9e438 (HEAD -> master, origin/master, origin/HEAD)
|
[pull] swiftwasm from main
No description provided.