解决方案
class Program
{
static void Main(string[] args)
{
CustomTest();
}
static void CustomTest()
{
List> keyValuePairs = new List>();
Dictionary temp = new Dictionary();
temp.Add("Name", "武松");
temp["Age"] = 28;
temp["Birthday"] = DateTime.Now;
keyValuePairs.Add(temp);
Dictionary temp1 = new Dictionary();
temp1.Add("Name", "睿智深");
temp1["Age"] = 31;
temp1["Birthday"] = DateTime.Now;
keyValuePairs.Add(temp1);
List dynamicsList = new List();
foreach (Dictionary keyValues in keyValuePairs)
{
dynamic obj = new System.Dynamic.ExpandoObject();
foreach (KeyValuePair keyValuePair in keyValues)
{
((IDictionary)obj).Add(keyValuePair.Key, keyValuePair.Value);
}
dynamicsList.Add(obj);
}
string paramsText = JsonConvert.SerializeObject(dynamicsList);
foreach (IDictionary keyValues in dynamicsList)
{
foreach (KeyValuePair keyValuePair in keyValues)
{
Console.WriteLine("Key:" + keyValuePair.Key + "; Value:" + keyValuePair.Value + "");
}
}
}
}