   // MARK: [JSONPrimitiveConvertible] type
   
   /// Decode an array of custom raw types with a mandatory key
-  public func jsonKeyPath<JSONPrimitiveConvertibleType : JSONPrimitiveConvertible>(_ key: Key) throws -> [JSONPrimitiveConvertibleType] {
-    
-    guard let jsonValues = self[keyPath: key] as? [JSONPrimitiveConvertibleType.JSONType] else {
-      throw DecodingError.mandatoryKeyNotFound(key: key)
+  public func jsonKeyPath<JSONPrimitiveConvertibleType : JSONPrimitiveConvertible>(_ keyPath: Key) throws -> [JSONPrimitiveConvertibleType] {
+    
+    guard let jsonValues = self[keyPath: keyPath] as? [JSONPrimitiveConvertibleType.JSONType] else {
+      throw DecodingError.mandatoryKeyNotFound(key: keyPath)
     }
     
     return jsonValues.flatMap {

  // MARK: RawRepresentable type
  
  /// Decode a mandatory RawRepresentable
  public func jsonKeyPath<ReturnType : RawRepresentable>(_ key: Key) throws -> ReturnType where ReturnType.RawValue:JSONRawType {
    
    guard let rawValue = self[key] as? ReturnType.RawValue else {
      throw DecodingError.mandatoryKeyNotFound(key: key)
    }
    
    guard let value = ReturnType(rawValue:rawValue) else {

  // MARK: JSONRawType type
  
  /// Decode a mandatory JSON raw type
  public func jsonKeyPath<ReturnType : JSONRawType>(_ keyPath: Key) throws -> ReturnType {
    
    guard let value = self[keyPath: keyPath] as? ReturnType else {
      throw DecodingError.mandatoryKeyNotFound(key: keyPath)
    }
    return value
  }
  
  /// Decode an optional JSON raw type
  public func jsonKeyPath<ReturnType : JSONRawType>(_ keyPath: Key) -> ReturnType? {
    return self[keyPath: keyPath] as? ReturnType
  }
  
  // MARK: [JSONRawType] type
  
  /// Decode an Array of mandatory JSON raw types
  public func jsonKeyPath<ReturnType : JSONRawType>(_ keyPath: Key) throws -> [ReturnType] {
    guard let value = self[keyPath: keyPath] as? [ReturnType] else {
      throw DecodingError.mandatoryKeyNotFound(key: keyPath)
    }
    return value
  }
  
  /// Decode an Array of optional JSON raw types
  public func jsonKeyPath<ReturnType : JSONRawType>(_ keyPath: Key) -> [ReturnType]? {
    return self[keyPath: keyPath] as? [ReturnType]
  }
  
  // MARK: [String: Any] type
  
  /// Decodes as a raw Dictionary with a mandatory key
  public func jsonKeyPath(_ keyPath: Key) throws -> JSONDictionary {
    
    guard let value = self[keyPath: keyPath] as? JSONDictionary else {
      throw DecodingError.mandatoryKeyNotFound(key: keyPath)
    }
    return value
  }

  /// Decodes as a raw dictionary with an optional key
  public func jsonKeyPath(_ keyPath: Key) -> JSONDictionary? {
    return self[keyPath: keyPath] as? JSONDictionary
  }
  
  // MARK: [[String: Any]] type
  
  /// Decodes as a raw dictionary array with a mandatory key
  public func jsonKeyPath(_ keyPath: Key) throws -> [JSONDictionary] {
    
    guard let value = self[keyPath: keyPath] as? [JSONDictionary] else {
      throw DecodingError.mandatoryKeyNotFound(key: keyPath)
    }
    return value
  }
  
  /// Decodes as a raw ictionary array with an optional key
  public func jsonKeyPath(_ keyPath: Key) -> [JSONDictionary]? {
    return self[keyPath: keyPath] as? [JSONDictionary]
  }

  
  // MARK: Decodable types
  
  /// Decode a mandatory Decodable object
  public func jsonKeyPath<ReturnType : JSONObjectConvertible>(_ keyPath: Key) throws -> ReturnType {
    return try ReturnType(jsonDictionary: JSONDictionaryForKey(keyPath))
  }
  
  /// Decode an optional Decodable object
  public func jsonKeyPath<ReturnType : JSONObjectConvertible>(_ keyPath: Key) -> ReturnType? {
    return try? ReturnType(jsonDictionary: JSONDictionaryForKey(keyPath))
  }
  
  // MARK: [Decodable] types
  
  /// Decode an Array of mandatory Decodable objects
  public func jsonKeyPath<ReturnType : JSONObjectConvertible>(_ keyPath: Key) throws -> [ReturnType] {
    return decodableObjectsArray(try JSONArrayForKey(keyPath))
  }
  
  /// Decode an Array of optional Decodable objects
  public func jsonKeyPath<ReturnType : JSONObjectConvertible>(_ keyPath: Key) -> [ReturnType]? {
    guard let jsonArray = try? JSONArrayForKey(keyPath) else {
      return nil
    }
    return decodableObjectsArray(jsonArray)
