I have been receiving JSON files in the following format:
{streetAddress: "Kosterlijand 20", postalCode: "3980", city: "Bunnik", country: "Netherlands"}
Although the length of these files varies, the structure always remains the same:
{key: "string value", key: "string value", etc...}
I have attempted to subscribe and retrieve this data, but I am facing challenges storing it properly. When using the code below:
this.service.getEntityDetails()
.subscribe(data => console.log(data));
The console displays the JSON data successfully. However, when I try to store the data in different variables as shown here:
public test: any[];
public test1: any[]=[];
public test2: string[];
public test3: string[]=[];
public test4: {};
constructor(service:Service){}
this.service.getEntityDetails()
.subscribe(data => {
test=data;
test1=data;
test2=data;
test3=data;
test4=data;
console.log("test:"+test+", test1: "+test1+", test2: "+test2+", test3: "+test3);
});
}
The output in the console remains the same for all variables.
test:[object Object], test1: [object Object], test2: [object Object], test3: [object Object] test4[object Object]
I aim to manipulate the data similar to how KeyValuePipe
works, yet I am unable to achieve this due to my inability to save the values appropriately. Any assistance on resolving this issue would be greatly appreciated.
Further details can be provided upon request.