How should I fetch images under an array using retrofit

后端 未结 1 1932
难免孤独
难免孤独 2020-12-07 03:54

I have images under array...here is my json:

{
    "status": 200,
    "data": {
        "id": 1,
        "product_category_         


        
相关标签:
1条回答
  • 2020-12-07 04:43

    Try this way...

    First off create model classes from your response, for that copy your response and add your response here http://pojo.sodhanalibrary.com/ , here it will create all pojo classes from your response.

    Now... change you api call method

    Call<Product_base_response>
    

    to

    Call<JsonObject>
    

    Now just print response in onResponse method like

    Log.d("===","onResponse :: "+response.body());
    

    if you got your response here,

       Gson gson = new Gson();
    Your_Main_Model mainModel = gson.fromJson(jsonObject.toString(), Your_Main_Model.class);
    

    Now, to get images you need to go through main model like

    Main_model.data_object_model.product_images_model_list.get(0).getImage();
    

    Hope this works, if you didn't get it or this not work let me know

    0 讨论(0)
提交回复
热议问题