M
mohaaron
Can anyone tell me how I can mimic the following code in .net 2.0?
This code works perfectly for converting the returned object to json
which I then use in javascript. I'm now on a project where I'm limited
to .net 2.0 and need to same functionality. Its the var data = new {}
that I need to mimic.
I'm using this inside of a web service.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Object GetData()
{
List<Person> people = new List<Person>()
{
new Person { FirstName="Andy", LastName="Todd", Age=21,
Height=221 },
new Person { FirstName="Dave", LastName="Nelson", Age=1, Height=1 },
new Person { FirstName="Lil", LastName="Edgar", Age=24,
Height=121 },
new Person { FirstName="Ian", LastName="Davis", Age=11, Height=190 }
};
// How can I do this in .net 2.0?
var data = new { rows = people, success = true, totalProperty =
people.Count};
return data;
}
This code works perfectly for converting the returned object to json
which I then use in javascript. I'm now on a project where I'm limited
to .net 2.0 and need to same functionality. Its the var data = new {}
that I need to mimic.
I'm using this inside of a web service.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Object GetData()
{
List<Person> people = new List<Person>()
{
new Person { FirstName="Andy", LastName="Todd", Age=21,
Height=221 },
new Person { FirstName="Dave", LastName="Nelson", Age=1, Height=1 },
new Person { FirstName="Lil", LastName="Edgar", Age=24,
Height=121 },
new Person { FirstName="Ian", LastName="Davis", Age=11, Height=190 }
};
// How can I do this in .net 2.0?
var data = new { rows = people, success = true, totalProperty =
people.Count};
return data;
}