I want to customize JavaScriptSerializer().Serialize by adding mapping. Make it clear:
Think we have class:(as it comes from other library I can't modify this class, so I can not use [JsonProperty("")] )
class Address
{
public string Number { get; set; }
public string Street { get; set; }
public string City { get; set; }
public string Country { get; set; }
}
output should be:
{
"NMB" : "No 25",
"STR" : "Main Street",
"CTY" : "Matale",
"CNT" : "Sri Lanka"
}
How can I achieve mapping during JavaScriptSerializer().Serialize(Address_Object);?
IMHO, the simpliest way would be to create an util to serialize, you can use a net serializer, or a Newtonsoft.Json one