I have a TypeScript class named order. The generic structure is as follows:
export class Order {
orderId : number= "";
email : string = "";
storeId : string = "";
date : string = "";
billing_address : Object = {};
systemId : string = "";
shipments : Object = {};
}
I want a way to convert this class into a JSON structure with a "order" key and the value being the fields of the order class. So it can look like this:
{
"order":{
"orderId":1232332,
"date": "06/02/2016,
etc....
}
}
After doing a quick test while writing this question, can I simply do let order_json = {"order": order}; and then later called JSON.stringify(order_json) to send it over an HTTP connection? My understanding is a JSON structure is simply a Javascript object in a particular format. Is this correct?