简体   繁体   中英

How to post JSON Array in retrofit using android?

I am working on retrofit but i have no idea how to post JSONArray in retrofit, i am posting the sample JSON please kindly go through it.

{
    "tab": [{
            "menu_item_id": "",
            "cost": 0,
            "quantity": 0,
            "name": ""
    }]
}

I am able to create JSONObject model but i am facing some issue in JSONArray model please kindly go through my sample JSON and suggest me some solution.

How did you declare the post method in your api interface? It should be something like this:

@POST("your/tabs/api/service/url") 
void postItemsMethod(@Field("tabs[]") ArrayList<YourItemClass> tabs , Callback<CallBackClass> callback);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM