Serialization in Swift

  • easy way to encode/decode to/from dictionary (or array) representation (in addition to Data). Also consider adding encoding/decoding directly to/from string.
  • opt-in's for not including default values during json encoding and a symmetrical opt-in for allowing absent values for variables that have default values during json decoding. example implementation
  • optional emitting explicit nils in json encoder. link
  • a way to decode JSON from data where Data contains something else after JSON (can be another json, or a separator, or something totally different.
    {"foo":"bar"} {"baz" : "qux"} ...
    this API will return me how many bytes are used, so I can continue parsing Data from offset, e.g. calling decoder another time.
  • allowsJSON5 for JSONEncoder (it's already supported for JSONDecoder).
  • more easy customization, e.g.:
    // straw man syntax:
    struct Foo: Codable {
        var id: Int                        // normal case
        @json(excluded) var bar: Int = 42 // not in json
        @json(excluded, default: 42) var bar: Int // or this if easier
        @json(renamed: "hello") var baz: Int // renamed
    }