Linked Questions

18 votes
6 answers
40k views

Convert C# List of object to JavaScript array of objects

I am using jQueryUI's autocomplete to allow the search of users. The documentation states that I am able to use an array for the source of the data in the following format: [ { label: "Choice1", value:...
Jeff's user avatar
  • 2,293
14 votes
2 answers
22k views

MVC3 JSON Serialization: How to control the property names?

I want to serialize a simple object to JSON: public class JsonTreeNode { [DataMember(Name = "title")] public string Title { get; set; } [DataMember(Name = "isFolder")] public bool ...
xsl's user avatar
  • 17.3k
4 votes
5 answers
20k views

Exclude property from json serialization in ApiController

I am trying to exclude properties from being serialized to JSON in web ApiControllers. I have verified the following 2 scenarios work. I have included the following attributes on the property I wish ...
Adam Carr's user avatar
  • 2,986
4 votes
2 answers
8k views

ASP.NET MVC 3 controller .Json method serialization doesn't look at DataMember Name attribure

In my class i've got: [DataMember(Name = "jsonMemberName", EmitDefaultValue = false, IsRequired = false)] public List<string> Member { get; set; } After passing the object through ...
WHITECOLOR's user avatar
  • 25.7k
3 votes
3 answers
8k views

Define JSON field names when using JsonResult

I have an action that returns a JsonResult in my ASP.Net MVC4 application. I'm setting the Data property to an array of pre-defined classes. My issue is that I want to serialize with different ...
Jason Butera's user avatar
  • 2,388
3 votes
1 answer
7k views

Json serialization in asp.net mvc c#

public ActionResult About() { List listStores = new List(); listStores = this.GetResults(“param”); return Json(listStores, “Stores”, JsonRequestBehavior.AllowGet); } Using the above code I am able to ...
pili's user avatar
  • 815
4 votes
1 answer
10k views

ASP.NET MVC: Json(IDictionary<string, string>) converts to array of key-value pairs

If I have an IDictionary<string, string> MyDictionary that resembles this: { {"foo", "bar"}, {"abc", "xyz"} } and in my MVC controller I have a method like so: [HttpPost] public ...
Jeremy Holovacs's user avatar
11 votes
1 answer
6k views

JavaScriptSerializer().Serialize : PascalCase to CamelCase

I have this javascript object var options: { windowTitle : '....', windowContentUrl : '....', windowHeight : 380, windowWidth : 480 } And I ...
user385411's user avatar
  • 1,455
1 vote
2 answers
7k views

HttpContext.Request.Form does not contain posted values in MVC

The following is an example how i am posting data to a controller action in MVC.The data is perfectly populating to my model object and working fine. var data={}; data.SearchText = 'abc' data....
shu's user avatar
  • 1,948
0 votes
3 answers
1k views

C#: Filter the members of an object

I have a model public class User : EntityObject { public int Id { get; set; } public string Username { get; set; } public string Password { get; set; } } and I would like to return to ...
Cristian Toma's user avatar
0 votes
1 answer
872 views

ASP.NET MVC Data annotations for json key

I Have a model in ASP.Net MVC something like this one. public class DataTable { public int RecordsTotal { get; set; } public int RecordsFiltered { get; set; } ...
jmvtrinidad's user avatar
  • 3,508
0 votes
2 answers
682 views

MVC3 portal handling JSON data from web service

I have to build small MVC3 ASP.NET based portal that will receive data in JSON form from other also MVC3 ASP.NET based web service. Service will get data from database, serialize it, and send it as ...
Admir Tuzović's user avatar