mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-08 21:14:47 +02:00
21 lines
424 B
Swift
21 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
|
||
|
}
|
||
|
}
|