用Newtonsoft.Json将list集合转成json

            List list = new List();
            list.Add(user);
            JsonSerializer serializer = new JsonSerializer();
            StringWriter sw = new StringWriter();
            serializer.Serialize(new JsonTextWriter(sw), list);
            string result = sw.GetStringBuilder().ToString();

list集合中是实体类,这样就能将实体类转成json

你可能感兴趣的:(用Newtonsoft.Json将list集合转成json)