title: iOS - Combine - Change Publisher type to child type
body: <p>I have these two Codable objects :</p>
  
  <pre><code>struct Parent: Codable {
      let name: String
      let children: [Child]
  }
  
  struct Child: Codable {
      let name: String
  } 
  </code></pre>
  
  <p>That I have created to match this json :</p>
  
  <pre><code>{
      name: "test"
      children: (
          {
            name: "test2"
          },
          {
            name: "test3"
          }
       )
  }
  </code></pre>
  
  <p>I retrieve the json and decode it to a Parent object using these methods :</p>
  
  <pre><code>func parent(_ url: String) -&gt; AnyPublisher&lt;Parent, Error&gt; { 
      return dataFromURL(url)
          .map(\.value)
          .eraseToAnyPublisher()
  }
  
  struct Result&lt;T&gt; {
      let value: T
      let response: URLResponse
  }
  
  func dataFromURL&lt;T: Decodable&gt;(_ url: String, _ decoder: JSONDecoder = JSONDecoder()) -&gt; AnyPublisher&lt;Result&lt;T&gt;, Error&gt; {
      let request = URLRequest(url: URL(string:url)!)
      return URLSession.shared
          .dataTaskPublisher(for: request)
          .tryMap { result -&gt; Result&lt;T&gt; in
              let value = try decoder.decode(T.self, from: result.data)
              return Result(value: value, response: result.response)
          }
          .receive(on: DispatchQueue.main)
          .eraseToAnyPublisher()
  }
  </code></pre>
  
  <p>It works, but I would like a method to retrieve the array of children, instead of the Parent object, like this :</p>
  
  <pre><code>func children(_ url: String) -&gt; AnyPublisher&lt;[Child], Error&gt;  
  </code></pre>
  
  <p>But I don't know what I need to change.. Any help would be appreciated, thanks !</p>