各种JSON格式数据

一、数组中有多个对象,对象中的字段是数组

[
  {
    "jingyesi": [
      "床前明月光",
      "疑是地上霜",
      "举头望明月",
      "低头思故乡"
    ]
  },
  {
    "youziyin": [
      "慈母手中线",
      "游子身上衣",
      "临行密密缝",
      "意恐迟迟归",
      "谁言寸草心",
      "报得三春晖"
    ]
  }
]

代码如下:

            //1.声明数组
            string[] arry1 = { "床前明月光", "疑是地上霜","举头望明月","低头思故乡"};
            //2、声明对象
            var obj1 = new JObject();
            //3、把数组加入对象中的字段
            obj1.Add("jingyesi",JArray.FromObject(arry1));

            string[] arry2 = {"慈母手中线","游子身上衣","临行密密缝","意恐迟迟归","谁言寸草心","报得三春晖"};
            var obj2 = new JObject();
            obj2.Add("youziyin",JArray.FromObject(arry2));
            //4.声明ogject的集合,把两个对象加入进去
            List<object> data = new List<object>() { obj1,obj2};

            Console.WriteLine(JArray.FromObject(data));

各种JSON格式数据

上一篇:js里面setInterval和setTimeout相同点和区别


下一篇:Kubernetes快速入门