Swiftpack.co - Fleuronic/Skewer as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Fleuronic.
Fleuronic/Skewer 1.3.0
🍡 Automatic support for “kebab-case” in Swift JSON encoders and decoders
⭐️ 30
🕓 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/Fleuronic/Skewer.git", from: "1.3.0")

Skewer 🍡

Provides support for "kebab-case" formatted (as opposed to just "snake_case" formatted) coding keys for JSONEncoder and JSONDecoder.


struct Website: Encodable {
    let homepageURLString: String

let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToKebabCase

let website = Website(homepageURLString: "http://www.apple.com")
let data = try! encoder.encode(website)
let json = try! JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]
let convertedKey = json.keys.first!
// homepage-url-string


struct App: Decodable {
    let downloadCount: Int

let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromKebabCase

let json = ["download-count": 999]
let data = try! JSONSerialization.data(withJSONObject: json, options: [])
let app = try! decoder.decode(App.self, from: data)
let downloadCount = app.downloadCount
// 999


Using the Swift Package Manager

Add Skewer as a dependency to your Package.swift file. For more information, see the Swift Package Manager documentation.

.package(url: "https://github.com/Fleuronic/Skewer", from: "1.0.0")


Skewer is available under the MIT license. See the LICENSE file for more info.


Stars: 30
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

5 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics