how can we convert our list item to Json formate?
Cheers
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhishek JainPosted Sep 18, 2013, 11:55 AM
, object>(list => list .Select(row=> new { }));
string json = new JavaScriptSerializer().Serialize(filter(list ));
Regards
AJ
Abhineet SrivastavaPosted Sep 18, 2013, 12:12 PM
Can you correct my linq query--
, object> filter =
, object>(list1 => list .Select(row=> new {FirstName="list.FirstName",LastName="list.LastName"}))
Abhineet SrivastavaPosted Sep 18, 2013, 12:06 PM
Abhishek JainPosted Sep 18, 2013, 12:02 PM
Regards
AJ
Abhineet SrivastavaPosted Sep 18, 2013, 12:00 PM
What will the namespace for JavaScriptSerializer?
Abhishek JainPosted Sep 18, 2013, 11:56 AM
Regards
AJ
Abhineet SrivastavaPosted Sep 18, 2013, 11:52 AM
is it right way to convert datatable to list?
Abhineet SrivastavaPosted Sep 18, 2013, 11:50 AM
Abhishek JainPosted Sep 18, 2013, 11:47 AM
Now for converting a List to JSON, you need a list and a filter which you need to create, so do something like this:
public class User
{
public string Id { get; set; }
public string Name { get; set; }
}
Suppose you have a list of users which you want to convert to JSON:
public IList
Creating Filter:
Converting it to JSON:
users.ToJson
Hope it helps.
Regards
AJ