title: Angular 2, v6: Write on assets/*.json file and save it [Typescript]
body: <p>:)</p>
  
  <p>I have an Angular application (@angular/cli: ~6.0.3, typescript: ~2.7.2) which have a json file in assets folder.
  I'm trying to access this json file, write on it and save it.</p>
  
  <p>How can I do that?</p>
  
  <p>Here is what I already try:</p>
  
  <pre><code>private jsonPath = 'assets/foods.json';
  
  public postJson(food: Food): Observable&lt;Food&gt; {
          const httpOptions = {
              headers: new HttpHeaders({
                  'Content-Type': 'application/json'
              })
          };
          return this._http.post(this.jsonPath, food, httpOptions);
      }
  </code></pre>
  
  <p>To test, I use:</p>
  
  <pre><code>public testJson() {
      const food = new Food('name1', '361');
      this.jsonService.postJson(food).subscribe(data =&gt; console.log('Post: ' + data));
      this.jsonService.getJson().subscribe((res: Food) =&gt; console.log(res));
    }
  </code></pre>
  
  <p>When I execute this.jsonService.getJson().subscribe((res: Food) => console.log(res));, I have as output the json without the new food that has been post early.</p>