I have object in my app in c# i need to serialize it to JSON but I need to custom the result json to be like below :
My class :
public class OrderStatus
{
public string title { get; set; }
public int statusNo { get; set; }
public string description { get; set; }
public string message { get; set; }
public string icon { get; set; }
}
I need to convert it to
{
"1": {
"icon": "orange_warning",
"title": "Pending Processing",
"message":
"We are processing your payment on our end which could take up to 30 minutes",
"description":
"Feel free to continue shopping while we process your payment. You can check the status of your order in Order History at any time."
},
"2": {
"icon": "done_success",
"title": "Order Successfully Placed",
"message": "",
"description":
"We have sent an email to your email address confirming your order."
}
}
the number is shown in json is StatusNo in my class I use this method to serialize the class
new JavaScriptSerializer().Serialize(model)