Add JsonArray to JsonObject

前端 未结 5 1797
予麋鹿
予麋鹿 2020-11-27 20:52

I googled a lot today for this subject. But I can\'t find it, How can I add a JSONArray to a JSONObject?

Because everytime I do this I get this error: Stackoverflow<

5条回答
  •  一整个雨季
    2020-11-27 21:30

    Just try below a simple solution:

    JsonObject body=new JsonObject();
    body.add("orders", (JsonElement) orders);
    

    whenever my JSON request is like:

    {
          "role": "RT",
          "orders": [
            {
              "order_id": "ORDER201908aPq9Gs",
              "cart_id": 164444,
              "affiliate_id": 0,
              "orm_order_status": 9,
              "status_comments": "IC DUE - Auto moved to Instruction Call Due after 48hrs",
              "status_date": "2020-04-15",
            }
          ]
        }
    

提交回复
热议问题