mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-08 13:04:41 +02:00
20 lines
424 B
Swift
20 lines
424 B
Swift
//
|
|
// Extensions.swift
|
|
// App
|
|
//
|
|
// Created by Rasmus Krämer on 14.04.22.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension String: Error {}
|
|
|
|
extension Encodable {
|
|
func asDictionary() throws -> [String: Any] {
|
|
let data = try JSONEncoder().encode(self)
|
|
guard let dictionary = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
|
|
throw NSError()
|
|
}
|
|
return dictionary
|
|
}
|
|
}
|