के साथ पार्स कॉम्प्लेक्स जेसन ऑब्जेक्ट्स मैं TypeScipt के साथ जटिल जेसन ऑब्जेक्ट को कैसे पार्स कर सकता हूं?टाइपस्क्रिप्ट
मेरे पास एक ग्राहक वस्तु है, जिसके पास कुछ चालान हैं।
यह मेरा मॉडल है:
export class Customer {
public id: string;
public name: string;
public invoices: CustomerInvoice[];
get invoicesCount(): number {
if (this.invoices== null) {
return 0;
}
return this.invoices.length;
}
constructor() {
}
}
export class CustomerInvoice {
public id: number;
constructor() {
}
}
और मेरी सेवा में मेरे पास है:
ngOnInit() {
if (this.id != null) {
this.dataService.getCustomer(this.id).subscribe(data => {
this.customer = data;
},
err => console.log(err));
}
}
ग्राहक डेटा (अपने ग्राहक आईडी, नाम आदि कुछ मान) महान हैं, लेकिन चालान अशक्त हैं ।
जेसन सही है, डेटा। चालान। लम्बाई एक संख्या लौटाती है।
पर्याप्त विवरण नहीं। – dfsq