title: Angular2: Http Client and reading from JSON containing a single object
body: <p>I am investigating Angular2 Http Client but I can't find out why I cannot do the below.</p>
  
  <p>I read the following JSON file:</p>
  
  <pre><code>{
    "id": 1,
    "surveyType": "Type1"
  }
  </code></pre>
  
  <p>into:</p>
  
  <pre><code>export class Survey {
      constructor(public id:number, public surveyType:string) {
  
      }
  }
  </code></pre>
  
  <p>using HTTP Client.</p>
  
  <p>In my service I call HTTP GET:</p>
  
  <pre><code>getSurvey() {
      return this.http
          .get(this.surveyUrl)
          .map((response:Response) =&gt; &lt;Survey&gt;response.json());
  }
  </code></pre>
  
  <p>Whereas in my component I have:</p>
  
  <pre><code>survey:Survey;
  
  ngOnInit() {
      this.getSurvey();
  }
  
  
  getSurvey() {
      this.surveyService.getSurvey()
          .subscribe(
              (survey:Survey) =&gt; {
                  this.survey = survey;
                  console.log(this.survey);
              },
              error =&gt; console.log(error)
          );
  }
  </code></pre>
  
  <p>My template contains only:</p>
  
  <pre><code>&lt;h1&gt;{{survey.id}}&lt;/h1&gt;
  </code></pre>
  
  <p>When executing the code, I always get errors.</p>
  
  <pre><code>TypeError: Cannot read property 'id' of undefined in [{{survey.id}} in SurveyComponent@0:4]
  </code></pre>
  
  <p>The context variable in stack trace reads:</p>
  
  <pre><code>context
      SurveyComponent
          survey
              Object id: 1, surveyType: Type1
  </code></pre>
  
  <p>Also in console I see the object:</p>
  
  <pre><code>Object {id: 1, surveyType: "Type1"}
  </code></pre>
  
  <p>My concerns:</p>
  
  <ol>
  <li>Why the returned object is not of type Survey?</li>
  <li>Why my survey object cannot be displayed using expression?</li>
  <li>Finally, how can I get such an example working? The API returns single object, not an array.</li>
  </ol>
  
  <p>I am using Angular2 Beta 11.</p>
  
  <p>Thanks in advance!</p>