title: ERROR SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>)
body: <p>I have the problem with function <code>JSON.parse()</code></p>
  
  <p>I used this because my data from a web server are always a string.
  I have this JSON</p>
  
  <pre><code> {
          "StatusCode": 0,
          "StatusMessage": "OK",
          "StatusDescription": 
             [
               {
                  "id": "1",
                  "datetime": "2018-04-13",
                  "data":"{ "id_data": "1S1S2ED333", "model": "02S", "serial_data": "123456" }"
               }
             ]
            }
  </code></pre>
  
  <p>I want to convert this string</p>
  
  <p><code>"{ "id_data": "1S1S2ED333", "model": "02S", "serial_data": "123456" }"</code></p>
  
  <p><em>to:</em> </p>
  
  <pre><code>{id_data: "1S1S2ED333", model: "02S",serial_data:"123456"}
  </code></pre>
  
  <p>I tried to convert:</p>
  
  <pre><code> export class Product{
          id: number;
          datetime: Date;
          data: string;
  
          constructor(obj: any) {
              this.id= obj.id;
              this.datetime= obj.datetime;
              this.data = obj.data;  //show "data":"{ "id_data": "1S1S2ED333", "model": "02S", "serial_data": "123456" }"
              this.data= JSON.parse(this.data); // show ERROR SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (&lt;anonymous&gt;)
              this.data = typeof this.data == "object"? this.data : typeof this.data == "string"? JSON.parse(this.data) : {}; `//show data:{}`
              this.data = obj &amp;&amp; JSON.stringify(this.data ); //undefined
  
              }
  public generateUrlencodedParameters(token: string, id?: number): string {
  
      let urlSearchParams = new URLSearchParams();
            urlSearchParams.append('data', this.data.toString());
            urlSearchParams.append('datatime', this.datatime.toString());
            urlSearchParams.append('token', token);
      return urlSearchParams.toString();
       }
      }
  </code></pre>
  
  <p>Can you suggest me, what is the problem?</p>
  
  <p>I want to display in html those data.</p>
  
  <p>When I tried</p>
  
  <pre><code>&lt;table *ngFor="let item of products"&gt;
     &lt;tr&gt;{{item.id}}&lt;/tr&gt;
     &lt;tr&gt;{{item.datatime}}&lt;/tr&gt;
     &lt;tr&gt;{{item.data}}&lt;/tr&gt; //show all string { "id_data": "1S1S2ED333", "model": "02S", "serial_data": "123456" }
  &lt;/table&gt;
  </code></pre>
  
  <p>I want to show only <code>model</code> and <code>serial_data</code> for this I have to do the string processing</p>