title: Transform nested JSON-Array into objects of typescript classes
body: <p>In the database are the two entities 'person' and 'name'. Between these two entities is a many to many relationship with the two properties 'from' and 'to'. </p>
  
  <pre><code>
   Person              PersonName                   Name
  ----------          -------------               -----------
  id: number          from: number                 id: number
                      to: number                   firstname: string
                                                   lastname: string
  </code></pre>
  
  <p>The Spring-Boot backend sends a json-array of all persons to the Angular frontend. </p>
  
  <p>A Json Object for a Person looks like this:</p>
  
  <pre><code>{
   id: 1, 
   names: [
      {
      from: 1733,
      to: 1735,
      name:  {
              id: 1,
              firstname: John,
              lastname: Doe
             }
      }, ...
  ]
  </code></pre>
  
  <p>My Angular service looks like this: </p>
  
  <pre><code>export class PersonService {
  
      constructor(private http: HttpClient) { }
  
      getAll(): Observable&lt;any&gt; {
          return this.http.get('//localhost:8080/person')
      };
  }
  </code></pre>
  
  <p>I build classes for the entities and the relationship. For example looks the name class like this:</p>
  
  <pre><code>export class Name {
      id: number;
      firstname: string;
      lastname: string;
  }
  </code></pre>
  
  <p>How can I transform the Json-Array to Objects of the Typescript classes? 
  The goal is that the getAll() returns an Observable of Type Person[].</p>
  
  <p>Changing <code>this.http.get('//localhost:8080/person')</code> to <code>this.http.get&lt;Person[]&gt;('//localhost:8080/person')</code> doesn't return a Person array.</p>