[swift-server-dev] JSON APIs
me at helgehess.eu
Thu Mar 2 04:49:02 CST 2017
I think it should probably replace JSON deserialisation stuff, maybe the whole plist stuff, in Foundation. IMO it is common enough to actually live in Foundation.
Do we need a Swift Extended Library? I’m pretty sure we don’t. There are plenty of ‘Swift Extended Libraries’ already and users can pick the ones they like just fine. Isn’t Zewo supposed to be such a "community supported package”?
If your concern is Foundation bloat, I think the solution to this is splitting Foundation into individual submodules (like Foundation.io, Foundation.http, Foundation.json, Foundation.security, etc).
Everything which should be ‘standard Swift’ and applies to both client&server should just live in Foundation. IMO.
P.S.: I’d hope that such a JSON library will properly support push-parsing/streaming, both when constructing JSON types (feed from NIO byte stream) as well as during generation of JSON (say when you fetch objects from a DB and then deliver them to a JSON client, you wouldn’t want to fetch all objects into memory to be able to generate JSON from them in a ’type-safe’ way). I don’t think this is particularly hard, but it needs to be considered, especially if the API would be sealed.
> On 2 Mar 2017, at 09:27, Swizzlr via swift-server-dev <swift-server-dev at swift.org> wrote:
> Tl;dr: I believe Swift's core libraries should include typesafe JSON handling.
> Preamble: Foundation's JSON serialisation is remarkably (and known to be) finicky, since it's mostly looking NS* objects. While this is a bug that could be rectified, the recursive JSON enum pattern has proven quite popular in recent months and I think something of this sort should be added to support typesafe JSON (de)structuring. This is a separate concern to writing a UTF-8 string; we already have parsers and writers in Swift that are pretty good.
> API design: we can go over this in a swift evolution proposal, we need to address another problem first:
> Where do we put it?!:
> The standard library is probably not the right place for a JSON type. With that out of the way, the Foundation library is overly constrained by its portability requirement with the unfortunately closed source implementation of Foundation on Apple platforms.
> Do we need a Swift Extended Library? Perhaps as a community supported package?
> Eager to hear the thoughts of all on this list.
> Sent from my iPhone
> swift-server-dev mailing list
> swift-server-dev at swift.org
More information about the swift-server-dev