text: Q:
  
  Store an object in JSON to output in NgxData-Table
  
  I'm using Ionic 4 and I want display a table based on the calculations from my inputs
  I have found a way to fetch data from a local JSON file but the issue here is I want to display data on a table based from calculated inputs rather than manual objects in JSON.
  This is the HTML file, I used ngx-datatable
  <ngx-datatable
          class="material"
          [rows]="rows"
          [columnMode]="'force'"
          [headerHeight]="50"
          [footerHeight]="50"
          [rowHeight]="'auto'">
          <ngx-datatable-column name="Month">
            <ng-template let-column="column" ngx-datatable-header-template>
              {{column.name}}
            </ng-template>
            <ng-template let-value="value" ngx-datatable-cell-template>
              <strong>{{value}}</strong>
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Interest">
          <ng-template let-column="column" let-sort="sortFn" ngx-datatable-header-template>
              <span (click)="sort()">{{column.name}}</span>
            </ng-template>
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
              <i>{{value}}</i>
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Principal">
            <ng-template let-value="value" ngx-datatable-cell-template>
              <strong>{{value}}</strong>
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Total">
            <ng-template let-column="column" ngx-datatable-header-template>
              {{column.name}}
            </ng-template>
            <ng-template let-value="value" ngx-datatable-cell-template>
              <strong>{{value}}</strong>
            </ng-template>
          </ngx-datatable-column>
          <ngx-datatable-column name="Balance">
            <ng-template let-column="column" ngx-datatable-header-template>
              {{column.name}}
            </ng-template>
            <ng-template let-value="value" ngx-datatable-cell-template>
              <strong>{{value}}</strong>
            </ng-template>
          </ngx-datatable-column>
        </ngx-datatable>
  
  This is from the TS File
  this.fetch((data) => {
        this.rows = data.splice(0, 5);
      });
  
  fetch(cb) {
      const req = new XMLHttpRequest();
      req.open('GET', `assets/data/company.json`);
  
      req.onload = () => {
        cb(JSON.parse(req.response));
      };
  
      req.send();
    }
  
  JSON File with mock data
  [
      {
          "month": "July/2019",
          "interest": "11111",
          "principal": "22222",
          "total": "33333",
          "balance": "44444"
      },
      {
          "month": "Dec/2019",
          "interest": "55555",
          "principal": "66666",
          "total": "77777",
          "balance": "88888"
      },
      {
          "month": "Jun/2019",
          "interest": "99999",
          "principal": "121212",
          "total": "232323",
          "balance": "343434"
      }
  ]
  
  I have calculated objects here:
  this.displayTotal = this.monthlyPayment;
  this.displayPrincipal = this.displayTotal - this.displayInterest;
  this.displayBalance = this.loanAmount - this.displayPrincipal; 
  this.displayInterest = (this.interestRate/this.loanTerm) * this.displayBalance;
  this.displayMonth = this.displayMonth;
  
  Is it possible to integrate those objects into the JSON file?
  
  A:
  
  Yes, it should be possible.
  First, you can turn the result from your input into JSON format:
  
  /*this.displayTotal = this.monthlyPayment;
  this.displayPrincipal = this.displayTotal - this.displayInterest;
  this.displayBalance = this.loanAmount - this.displayPrincipal; 
  this.displayInterest = (this.interestRate/this.loanTerm) * this.displayBalance;
  this.displayMonth = this.displayMonth;*/
  //demo mocknumber:
  
  var displayMonth = 1000;
  var displayInterest = 10;
  var displayPrincipal = 100;
  var displayTotal = 1000;
  var displayBalance = 10000;
  
  var json = [{
    "month": this.displayMonth,
    "interest": this.displayInterest,
    "principal": this.displayPrincipal,
    "total": this.displayTotal,
    "balance": this.displayBalance,
  }];
  
  console.log(json);
  
  Then you can try as this answer said (with modification):
  var a = document.createElement('a');
  a.setAttribute('href', 'data:text/plain;charset=utf-u,' + encodeURIComponent(JSON.stringify(this.json)));
  a.setAttribute('download', this.filename);
  a.click()
  
  Demo: https://stackblitz.com/edit/angular-m5wd2x?file=src/app/app.component.ts
  
  