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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhishek JainRank #1,062 · 1.8K reputationPosted Sep 18, 2013, 7:55 AM EDT
, object>(list => list .Select(row=> new { }));
string json = new JavaScriptSerializer().Serialize(filter(list ));
Regards
AJ
Abhishek JainRank #1,062 · 1.8K reputationPosted Sep 18, 2013, 7:47 AM EDT
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
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Sep 18, 2013, 7:50 AM EDT
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Sep 18, 2013, 7:52 AM EDT
is it right way to convert datatable to list?
Abhishek JainRank #1,062 · 1.8K reputationPosted Sep 18, 2013, 7:56 AM EDT
Regards
AJ
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Sep 18, 2013, 8:00 AM EDT
What will the namespace for JavaScriptSerializer?
Abhishek JainRank #1,062 · 1.8K reputationPosted Sep 18, 2013, 8:02 AM EDT
Regards
AJ
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Sep 18, 2013, 8:06 AM EDT
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Sep 18, 2013, 8:12 AM EDT
Can you correct my linq query--
, object> filter =
, object>(list1 => list .Select(row=> new {FirstName="list.FirstName",LastName="list.LastName"}))