 
 /// Converts an object to a JSON string
 /// @throws errors if deserialization fails
-func serialize<T>(_ value: T) throws -> Data where T : Encodable {
+public func serialize<T>(_ value: T) throws -> Data where T : Encodable {
     return try! encoder.encode(value)
 }
 


/// handling date strings in JSON
/// https://stackoverflow.com/questions/44682626/swifts-jsondecoder-with-multiple-date-formats-in-a-json-string
extension JSONDecoder {
    
    /// Assign multiple DateFormatter to dateDecodingStrategy
    ///

/// Convert a JSON string into the type `T`
/// @throws errors if deserialization fails
@available(OSX 10.12, *)
public func deserialize<T>(_ json: String) throws -> T where T : Codable {
    return try deserialize(Data(json.utf8))
}

/// Support for converting a struct or class to a Dictionary of values
/// Code from https://stackoverflow.com/a/46597941/74137
public struct JSON {
    static let encoder = JSONEncoder()
}

public extension Encodable {
    subscript(key: String) -> Any? {
        return dictionary[key] as Any?
    }
