Hello, I am looking to convert the RestController Response from a Json String to a json array. Below is the json string that I have printed in the console:
'{"Impressions":["Budget","CTR","Campaign","Campaign state","Clicks","Conv. rate"],"Clicks":["Budget","CTR","Campaign","Campaign state","Clicks","Conv. rate"],"Revenue":["Budget","CTR","Campaign","Campaign state","Clicks","Conv. rate"]}'
My goal is to convert it into a json array so that I can iterate over it.
The purpose of this iteration is to use the key as a label and the corresponding values as select options.
For example:
"Impression" would be the label with options "Budget","CTR","Campaign","Campaign state","Clicks","Conv. rate".
Here is the code snippet for iterating through the array:
<div>
<form *ngFor ="let map of mapper">
<mat-form-field>
<mat-select placeholder="{{map}}">
<mat-option *ngFor="let option of map" [value]="option">
{{option}}
</mat-option>
</mat-select>
</mat-form-field>
</form>
</div>
And here is my .ts class code:
this.clientService.getHeaders().subscribe(
(res) => {
console.log(res);
let resSTR = JSON.stringify(res);
let resJSON = JSON.parse(resSTR);
this.mapper=Array.of(resJSON._body);
console.log(this.mapper);
this.ismapped=false;
}
);