title: Angular2 map json to object
body: <p>I have a java rest service that returns the following json:</p>
  
  <p>Json Output</p>
  
  <pre><code> {
      "description": "Temperature Sensor",
      "symbol": "°C",
      "name": "degree celsius",
      "maxMeasure": {
          "quantity": 12.8,
          "name": "degree celsius",
          "symbol": "°C",
          "dateTime": "2018-03-15T12:38:23"
      },
      "measure": {
          "quantity": 11.1,
          "name": "degree celsius",
          "symbol": "°C",
          "dateTime": "2018-03-15T18:34:27"
      },
      "minMeasue": {
          "quantity": 5.8,
          "name": "degree celsius",
          "symbol": "°C",
          "dateTime": "2018-03-15T04:09:24"
      },
      "conversionFactor": 1
  }
  </code></pre>
  
  <p>through this angular service i call the endpoint :</p>
  
  <p>SensorService.ts</p>
  
  <pre><code>getSensor(sensorId: string): Observable&lt;Sensor&gt; {
        const headers = new Headers();
        headers.append('Content-Type', 'application/json');
        headers.append('token', 'token');
        headers.append('sensorId', sensorId);
        headers.append('unitMeasureId', '1');
        const options = new RequestOptions({ headers: headers });
        return this._http.get(this._sensorurl, options)
          .map(data =&gt; &lt;Sensor&gt; data.json())
          .do(data =&gt; console.log(data));
     }
  </code></pre>
  
  <p>and i map the result in this classes:</p>
  
  <p>Sensor.ts</p>
  
  <pre><code>export class Sensor {
    description: string;
    symbol: string;
    name: string;
    maxMeasure: Measure;
    measure: Measure;
    minMeasue: Measure;
    conversionFactor: number;
  }
  </code></pre>
  
  <p>Measure.ts</p>
  
  <pre><code>export class Measure {
      quantity: string;
      name: string;
      symbol: string;
      dateTime: string;
  }
  </code></pre>
  
  <p>with this statement:</p>
  
  <p>sensor.component.ts</p>
  
  <pre><code> ngOnInit(): void {
        this._sensor.getSensor(this.route.snapshot.paramMap.get('id'))
            .subscribe(sensor =&gt; this.sensor = sensor);
      }
  </code></pre>
  
  <p>the json is correctly read because by the console I can read it, but when it is mapped on the Sensor object give an undefined output.</p>
  
  <p>where is that wrong?</p>