title: What is the more elegant way to serialize my own objects with arrays in Swift
body: <p>I have a classes that looks like this:</p>
  
  <pre><code>class Foo {
      var bar = Int()
  }
  
  class Bar {
      var baz = String()
      var arr = [Foo]()
  }
  </code></pre>
  
  <p>and I have an object of Bar structure that I need to serialize to JSON:</p>
  
  <pre><code>let instance = Bar()
  </code></pre>
  
  <p>What is the more elegant way to do it via standard library or some third-party libraries?</p>
  
  <p>Thanks in advance.</p>