Two modes of conversion:
1. Global settings, set for GlobalConfiguration.Configuration.Formatters.JsonFormatter , located in global.asax such as:
varJSON =Globalconfiguration.configuration.formatters.jsonformatter;json. Serializersettings.formatting=Newtonsoft.json.formatting.indented;json. Serializersettings.contractresolver=NewCamelcasepropertynamescontractresolver (); JSON. Serializersettings.nullvaluehandling=Newtonsoft.json.nullvaluehandling.ignore;json. Serializersettings.dateformathandling=Newtonsoft.json.dateformathandling.microsoftdateformat;json. Serializersettings.datetimezonehandling=Newtonsoft.json.datetimezonehandling.utc;json. Serializersettings.culture=NewCultureInfo ("it-it");
2. Set individually, for individual action code snippets such as:
varFormatter =NewJsonmediatypeformatter ();varJSON =Formatter. Serializersettings;json. Dateformathandling=Newtonsoft.json.dateformathandling.microsoftdateformat;json. Datetimezonehandling=Newtonsoft.json.datetimezonehandling.utc;json. Nullvaluehandling=Newtonsoft.json.nullvaluehandling.ignore;json. Formatting=Newtonsoft.json.formatting.indented;json. Contractresolver=NewCamelcasepropertynamescontractresolver (); JSON. Culture=NewCultureInfo ("it-it");returnRequest.createresponse (Httpstatuscode.ok, result, formatter);
Reference Source: http://tostring.it/2012/07/18/customize-json-result-in-web-api/
Since this article is understood, it seems that English is not unable to learn! Come on!
WebApi JSON formatting