title: Can I serialize a RealmObject to JSON or to NSDictionary in Realm for Swift?
body: <p>I'm testing Realm, but I cant find a easy way to convert my object to JSON. 
  I need to push the data to my REST interface. 
  How can I do it using swift?</p>
  
  <pre><code>class Dog: Object {
    dynamic var name = ""
  }
  
  class Person : Object {
    dynamic var name = ""
    let dogs = List&lt;Dog&gt;()
  }
  </code></pre>
  
  <p>I'm trying something like this, but I can't iterate unknown objects (List)</p>
  
  <pre><code>extension Object {
    func toDictionary() -&gt; NSDictionary {
      let props = self.objectSchema.properties.map { $0.name }
      var dicProps = self.dictionaryWithValuesForKeys(props)
  
      var mutabledic = NSMutableDictionary()
      mutabledic.setValuesForKeysWithDictionary(dicProps)
  
      for prop in self.objectSchema.properties as [Property]! {
  
        if let objectClassName = prop.objectClassName  {
          if let x = self[prop.name] as? Object {
            mutabledic.setValue(x.toDictionary(), forKey: prop.name)
          } else {
            //problem here!
          }
        }
      }
      return mutabledic
    }
  }
  </code></pre>
  
  <p>**sorry for ugly code.</p>