[swift-server-dev] JSON APIs

Swizzlr me at swizzlr.co
Thu Mar 2 02:27:31 CST 2017

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

More information about the swift-server-dev mailing list