c# - How to force camelcase with JavaScriptSerializer? -


is possible?

i have class this:

public class abc {     [key]     [scriptignore]     public int id { get; set; }      public string name { get; set; }      public string anotherfield { get; set; }      [scriptignore]     public virtual user user { get; set; } } 

but serialize { "name":"foo", "anotherfield":"bar" } instead of { "name":"foo", "anotherfield":"bar" }.

this how use:

return request.createresponse(httpstatuscode.ok, new javascriptserializer().serialize(obj)); 

you can use camel case resolver newtonsoft.json.serialization; on global.asax register on application start

using newtonsoft.json.serialization;  protected void application_start() {      config.formatters.jsonformatter.serializersettings.contractresolver = new camelcasepropertynamescontractresolver(); } 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -