Swiftpack.co - Package - malt03/URLQueryItemsCoder

URLQueryItemsCoder Build Status SwiftPM compatible License

URLQueryItemsCoder is a library for encoding an Encodable to [URLQueryItem].

Usage

The query items order is guaranteed.

struct Property: Encodable {
    let a = 1
    let b = [2, 3]
    let c = C()

    struct C: Encodable {
        let a = 4
    }
}

var urlComponents = URLComponents(string: "http://example.com")
urlComponents?.queryItems = try! URLQueryItemsEncoder().encode(Property())
print(urlComponents?.url?.absoluteString ?? "") // http://example.com?a=1&b%5B0%5D=2&b%5B1%5D=3&c%5Ba%5D=4 => a=1&b[0]=2&b[1]=3&c[a]=4

Installation

SwiftPM (Recommended)

  • On Xcode, click File > Swift Packages > Add Package Dependency...
  • Input https://github.com/malt03/URLQueryItemsCoder.git

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

0.0.2 - 2020-01-09 04:51:55

order guarantee

0.0.1 - 2020-01-08 10:02:55