How to add jarray Object into JObject

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

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

paramete         


        
4条回答
  •  旧巷少年郎
    2021-02-05 03:50

    it is easy,

    JArray myarray = new JArray();
    JObject myobj = new JObject();
    // myobj.add(myarray); -> this is wrong. you can not add directly.
    
    JProperty subdatalist = new JProperty("MySubData",myarray);
    myobj.Add(subdata); // this is the correct way I suggest.
    

提交回复
热议问题