var config2 = new { age = 20, desc = "A student in high school", experience = new { first = "Grade 6 of primary school won the third prize in football", second = "I was the first in my class in the final exam of the third year of junior high school" } } var mergeConfig = TypeMerger.TypeMerger.Merge(config1, config2); var configString = JsonConvert.SerializeObject(mergeConfig); Console.WriteLine(configString);
返回结果:
1 2 3 4 5 6 7 8 9
{ "name":"Tom", "age":18, "desc":"A student in high school", "experience":{ "first":"Grade 6 of primary school won the third prize in football", "second":"I was the first in my class in the final exam of the third year of junior high school" } }