Thursday, 19 September 2013

Get JSON Object Array

Get JSON Object Array

I am building my application based on another similar application. I am
using firebug to attempt to get the same Response / JSON.
In the working application the "Response" tab says:
and the "JSON" tab shows several JSON objects with associated properties:
In the broken application the "Response" tab says:
(It put a "d" key around the data and escaped all the double quotes)
and the "JSON" tab just shows a single object d that contains a string of
the data:
The method that is called to return the "broken" JSON response is:
public static string GetMembers()
{
Member member1 = new Member();
member1.Id = 1;
member1.FirstName = "John";
member1.LastName = "Smith";
Member member2 = new Member();
member2.Id = 2;
member2.FirstName = "Bruce";
member2.LastName = "Banner";
List<Member> members = new List<Member>();
members.Add(member1);
members.Add(member2);
return new JavaScriptSerializer().Serialize(members);
}
What can I do to my method to make it return / display the JSON data the
same way as the first application?
Note I don't have the source of the first application, I am just looking
at the page it loads in firebug.

No comments:

Post a Comment