I'm getting a product list from a JSON file like
products.service
getProducts(): Observable<Product[]>{
return this._http.get<Product[]>(this.configUrl);
}
products.component
getProducts(): void{
this.productsService.getProducts()
.subscribe(productList =>{
this.products = productList['products'];
} );
}
product.interface
export interface Product {
"quantity": number;
"price": number;
"available": boolean;
"sublevel_id": number;
"name": string;
"id": string;
}
Json example
0:
available: false
id: "58b5a5b1b6b6c7aacc25b3fb"
name: "aute"
price: "$8,958"
quantity: 308
sublevel_id: 3
1:
available: true
id: "58b5a5b117bf36cf8aed54ab"
name: "mollit"
price: "$5,450"
quantity: 891
sublevel_id: 3
Price property is stored in json as string but I would like to store it in my variable this.products
as a number because I will operate with them several times
How is the best way to do it?