How to add jarray Object into JObject

前端 未结 4 1607
旧巷少年郎
旧巷少年郎 2021-02-05 03:07

How to add JArray into JObject? I am getting an exception when changing the jarrayObj into JObject.

paramete         


        
4条回答
  •  旧时难觅i
    2021-02-05 03:44

    var jObject = new JObject();
    jObject.Add("birthday", "2011-05-06");
    jObject.Add("email", "dude@test.com");
    var items = new [] { "Item1", "Item2", "Item3" };
    var jSonArray = JsonConvert.SerializeObject(items);
    var jArray = JArray.Parse(jSonArray);
    jObject.Add("_delete", jArray);
    

提交回复
热议问题