[swift-corelibs-dev] Implementing JSONSerialization.jsonObject(with stream)

Philippe Hausler phausler at apple.com
Fri Jul 15 09:50:04 CDT 2016


We had changed the return type of JSONSerialization to be Any such that it avoided the caller needing to bridge types (which works poorly on linux). Even though this is an API change technically, just change the return type to match the other JSONSerialization methods.

> On Jul 15, 2016, at 12:44 AM, Mamatha Busi via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> 
> Hi
>  
> Trying to implement the JSONSerialization unimplemented method jsonObject(withStream). 
>  
>  JSONSerialization.jsonObject(with stream: InputStream, options opt: ReadingOptions = []) throws -> AnyObject
>  
> The comments in the source code mentions that apart from stream configuration all other behaviour of this method is the same as the JSONObjectWithData:options:error.
> This implies that I can internally reuse the JSONObjectWithData method, however its return type is ‘Any’ whereas the return type in jsonObjectWithStream is ‘AnyObject’. As I cannot downcast ‘Any’ to ‘AnyObject’, I’m looking for inputs if I should rewrite the behaviour or is there any other way?
>  
> Thank you.
>  
> -Mamatha.
> 
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160715/1ad3252c/attachment.html>


More information about the swift-corelibs-dev mailing list