C# 生成Json数据

using Newtonsoft.Json;
                StringWriter sw = new StringWriter();
                JsonWriter writer = new JsonTextWriter(sw);

                writer.WriteStartObject();

                foreach (Control item in flpModule.Controls)
                {
                    if (item is UC_Module)
                    {
                        UC_Module UM = (UC_Module)item;
                        writer.WritePropertyName(UM.lbModule.Text);
                        writer.WriteValue(decimal.Parse(UM.tbScore.Text));
                    }
                }

                writer.WriteEndObject();

                Console.WriteLine(sw.ToString());

你可能感兴趣的:(C#)