title: ObjectMapper how to map different object based on JSON
body: <p>I'm using ObjectMapper (<a href="https://github.com/Hearst-DD/ObjectMapper" rel="noreferrer">https://github.com/Hearst-DD/ObjectMapper</a>) to map my JSON to Swift objects.</p>
  
  <p>Say I have this JSON structure:</p>
  
  <pre><code>{
    animals: [
      {
        "type": "Cat",
        "weight": 23,
        "catchMice": true
      },
      {
        "type": "Fish",
        "weight": 1,
        "swim": true
      }
    ]
  }
  </code></pre>
  
  <p>I have the following Swift objects:</p>
  
  <pre><code>class Foo: Mappable {
    var animals: [Animal] = []
  
    func mapping(map: Map) {
      animals &lt;- map["animals"] //But I want to be able to distinguish between Cat and Fish objects here
    }
  }
  
  class Animal: Mappable {
    var type: String?
    var weight: Double?
  
    required init?(map: Map) {}
  
    func mapping(map: Map) {
      type &lt;- map["type"]
      weight &lt;- map["weight"]
    }
  }
  
  class Cat: Animal { // How do I make use of this class
    var catchMice: Bool?
  }
  
  class Fish: Animal { // How do I make use of this class 
    var swim: Bool?
  }
  </code></pre>
  
  <p>How can I distinguish between <code>Cat</code> and <code>Fish</code> in my mapping using the <code>type</code> key in my JSON objects? Thanks so much!</p>