converting list to json format - quick and easy way

后端 未结 7 1684
梦如初夏
梦如初夏 2020-12-05 09:56

Let\'s say I have an object MyObject that looks like this:

public class MyObject
{
  int ObjectID {get;set;}
  string ObjectString {get;set;}
} 
相关标签:
7条回答
  • 2020-12-05 10:23

    3 years of experience later, I've come back to this question and would suggest to write it like this:

    string output = new JavaScriptSerializer().Serialize(ListOfMyObject);
    

    One line of code.

    0 讨论(0)
提交回复
热议问题