Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从以下响应创建自定义GsonConverter?_Android_Json_Gson_Retrofit2 - Fatal编程技术网

Android 如何从以下响应创建自定义GsonConverter?

Android 如何从以下响应创建自定义GsonConverter?,android,json,gson,retrofit2,Android,Json,Gson,Retrofit2,这是我的JSON [{ "NEW ARRIVALS": { "new-arrivals": [] } }, { "ACCESSORIES": { "accessories": [{ "SHOP BY CATEGORY": [{ "Earrings": "earrings" }, { "Necklace & Pendent

这是我的
JSON

[{
    "NEW ARRIVALS": {
        "new-arrivals": []
    }
}, {
    "ACCESSORIES": {
        "accessories": [{
            "SHOP BY CATEGORY": [{
                "Earrings": "earrings"
            }, {
                "Necklace & Pendent Sets": "necklace-pendent-sets"
            }, {
                "Blouses": "blouses"
            }, {
                "Bottom Wear": "bottom-wear"
            }, {
                "Duppattas": "duppattas"
            }, {
                "...View all": "accessories"
            }]
        }, {
            "SHOP BY MATERIAL": [{
                "Crape": "accessories"
            }, {
                "Silk": "accessories"
            }, {
                "Chanderi": "accessories"
            }, {
                "Bhagalpuri": "accessories"
            }]
        }, {
            "SHOP BY COLOR": [{
                "White": "accessories"
            }, {
                "Blue": "accessories"
            }, {
                "Black": "accessories"
            }, {
                "Green": "accessories"
            }, {
                "Pink": "accessories"
            }, {
                "Beige": "accessories"
            }, {
                "Red": "accessories"
            }, {
                "Yellow": "accessories"
            }, {
                "Orange": "accessories"
            }, {
                "...View all": "accessories"
            }]
        }, {
            "SHOP BY PRODUCT TYPE": [{
                "Accessories": "accessories"
            }, {
                "Stitched": "accessories"
            }]
        }, {
            "SHOP BY PRICE": [{
                "Rs.0 - Rs.499": "accessories"
            }, {
                "Rs.500 - Rs.999": "accessories"
            }, {
                "Rs.1000 - Rs.1499": "accessories"
            }, {
                "Rs.1500 - Rs.1999": "accessories"
            }, {
                "Rs.2000 and above": "accessories"
            }, {
                "...View all": "accessories"
            }]
        }]
    }
}]

使用这些模型类并通过Gson直接传递您的响应

com.example.ACCESSORIES.java

package com.example;

import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class ACCESSORIES {

    @SerializedName("accessories")
    @Expose
    private List<Accessory> accessories = null;

    public List<Accessory> getAccessories() {
        return accessories;
    }

    public void setAccessories(List<Accessory> accessories) {
        this.accessories = accessories;
    }
}
com.example.NEWARRIVALS.java

package com.example;

import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class NEWARRIVALS {

    @SerializedName("new-arrivals")
    @Expose
    private List<Object> newArrivals = null;

    public List<Object> getNewArrivals() {
        return newArrivals;
    }

    public void setNewArrivals(List<Object> newArrivals) {
        this.newArrivals = newArrivals;
    }
}
com.example.SHOPBYCOLOR.java

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYCOLOR {

    @SerializedName("White")
    @Expose
    private String white;
    @SerializedName("Blue")
    @Expose
    private String blue;
    @SerializedName("Black")
    @Expose
    private String black;
    @SerializedName("Green")
    @Expose
    private String green;
    @SerializedName("Pink")
    @Expose
    private String pink;
    @SerializedName("Beige")
    @Expose
    private String beige;
    @SerializedName("Red")
    @Expose
    private String red;
    @SerializedName("Yellow")
    @Expose
    private String yellow;
    @SerializedName("Orange")
    @Expose
    private String orange;
    @SerializedName("...View all")
    @Expose
    private String viewAll;

    public String getWhite() {
        return white;
    }

    public void setWhite(String white) {
        this.white = white;
    }

    public String getBlue() {
        return blue;
    }

    public void setBlue(String blue) {
        this.blue = blue;
    }

    public String getBlack() {
        return black;
    }

    public void setBlack(String black) {
        this.black = black;
    }

    public String getGreen() {
        return green;
    }

    public void setGreen(String green) {
        this.green = green;
    }

    public String getPink() {
        return pink;
    }

    public void setPink(String pink) {
        this.pink = pink;
    }

    public String getBeige() {
        return beige;
    }

    public void setBeige(String beige) {
        this.beige = beige;
    }

    public String getRed() {
        return red;
    }

    public void setRed(String red) {
        this.red = red;
    }

    public String getYellow() {
        return yellow;
    }

    public void setYellow(String yellow) {
        this.yellow = yellow;
    }

    public String getOrange() {
        return orange;
    }

    public void setOrange(String orange) {
        this.orange = orange;
    }

    public String getViewAll() {
        return viewAll;
    }

    public void setViewAll(String viewAll) {
        this.viewAll = viewAll;
    }
}
com.example.SHOPBYMATERIAL.java

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYMATERIAL {

    @SerializedName("Crape")
    @Expose
    private String crape;
    @SerializedName("Silk")
    @Expose
    private String silk;
    @SerializedName("Chanderi")
    @Expose
    private String chanderi;
    @SerializedName("Bhagalpuri")
    @Expose
    private String bhagalpuri;

    public String getCrape() {
        return crape;
    }

    public void setCrape(String crape) {
        this.crape = crape;
    }

    public String getSilk() {
        return silk;
    }

    public void setSilk(String silk) {
        this.silk = silk;
    }

    public String getChanderi() {
        return chanderi;
    }

    public void setChanderi(String chanderi) {
        this.chanderi = chanderi;
    }

    public String getBhagalpuri() {
        return bhagalpuri;
    }

    public void setBhagalpuri(String bhagalpuri) {
        this.bhagalpuri = bhagalpuri;
    }
}
com.example.SHOPBYPRICE.java

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYPRICE {

    @SerializedName("Rs.0 - Rs.499")
    @Expose
    private String rs0Rs499;
    @SerializedName("Rs.500 - Rs.999")
    @Expose
    private String rs500Rs999;
    @SerializedName("Rs.1000 - Rs.1499")
    @Expose
    private String rs1000Rs1499;
    @SerializedName("Rs.1500 - Rs.1999")
    @Expose
    private String rs1500Rs1999;
    @SerializedName("Rs.2000 and above")
    @Expose
    private String rs2000AndAbove;
    @SerializedName("...View all")
    @Expose
    private String viewAll;

    public String getRs0Rs499() {
        return rs0Rs499;
    }

    public void setRs0Rs499(String rs0Rs499) {
        this.rs0Rs499 = rs0Rs499;
    }

    public String getRs500Rs999() {
        return rs500Rs999;
    }

    public void setRs500Rs999(String rs500Rs999) {
        this.rs500Rs999 = rs500Rs999;
    }

    public String getRs1000Rs1499() {
        return rs1000Rs1499;
    }

    public void setRs1000Rs1499(String rs1000Rs1499) {
        this.rs1000Rs1499 = rs1000Rs1499;
    }

    public String getRs1500Rs1999() {
        return rs1500Rs1999;
    }

    public void setRs1500Rs1999(String rs1500Rs1999) {
        this.rs1500Rs1999 = rs1500Rs1999;
    }

    public String getRs2000AndAbove() {
        return rs2000AndAbove;
    }

    public void setRs2000AndAbove(String rs2000AndAbove) {
        this.rs2000AndAbove = rs2000AndAbove;
    }

    public String getViewAll() {
        return viewAll;
    }

    public void setViewAll(String viewAll) {
        this.viewAll = viewAll;
    }
}
com.example.SHOPBYPRODUCTTYPE.java

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYPRODUCTTYPE {

    @SerializedName("Accessories")
    @Expose
    private String accessories;
    @SerializedName("Stitched")
    @Expose
    private String stitched;

    public String getAccessories() {
        return accessories;
    }

    public void setAccessories(String accessories) {
        this.accessories = accessories;
    }

    public String getStitched() {
        return stitched;
    }

    public void setStitched(String stitched) {
        this.stitched = stitched;
    }
}

谢谢你的指导
package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYMATERIAL {

    @SerializedName("Crape")
    @Expose
    private String crape;
    @SerializedName("Silk")
    @Expose
    private String silk;
    @SerializedName("Chanderi")
    @Expose
    private String chanderi;
    @SerializedName("Bhagalpuri")
    @Expose
    private String bhagalpuri;

    public String getCrape() {
        return crape;
    }

    public void setCrape(String crape) {
        this.crape = crape;
    }

    public String getSilk() {
        return silk;
    }

    public void setSilk(String silk) {
        this.silk = silk;
    }

    public String getChanderi() {
        return chanderi;
    }

    public void setChanderi(String chanderi) {
        this.chanderi = chanderi;
    }

    public String getBhagalpuri() {
        return bhagalpuri;
    }

    public void setBhagalpuri(String bhagalpuri) {
        this.bhagalpuri = bhagalpuri;
    }
}
package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYPRICE {

    @SerializedName("Rs.0 - Rs.499")
    @Expose
    private String rs0Rs499;
    @SerializedName("Rs.500 - Rs.999")
    @Expose
    private String rs500Rs999;
    @SerializedName("Rs.1000 - Rs.1499")
    @Expose
    private String rs1000Rs1499;
    @SerializedName("Rs.1500 - Rs.1999")
    @Expose
    private String rs1500Rs1999;
    @SerializedName("Rs.2000 and above")
    @Expose
    private String rs2000AndAbove;
    @SerializedName("...View all")
    @Expose
    private String viewAll;

    public String getRs0Rs499() {
        return rs0Rs499;
    }

    public void setRs0Rs499(String rs0Rs499) {
        this.rs0Rs499 = rs0Rs499;
    }

    public String getRs500Rs999() {
        return rs500Rs999;
    }

    public void setRs500Rs999(String rs500Rs999) {
        this.rs500Rs999 = rs500Rs999;
    }

    public String getRs1000Rs1499() {
        return rs1000Rs1499;
    }

    public void setRs1000Rs1499(String rs1000Rs1499) {
        this.rs1000Rs1499 = rs1000Rs1499;
    }

    public String getRs1500Rs1999() {
        return rs1500Rs1999;
    }

    public void setRs1500Rs1999(String rs1500Rs1999) {
        this.rs1500Rs1999 = rs1500Rs1999;
    }

    public String getRs2000AndAbove() {
        return rs2000AndAbove;
    }

    public void setRs2000AndAbove(String rs2000AndAbove) {
        this.rs2000AndAbove = rs2000AndAbove;
    }

    public String getViewAll() {
        return viewAll;
    }

    public void setViewAll(String viewAll) {
        this.viewAll = viewAll;
    }
}
package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class SHOPBYPRODUCTTYPE {

    @SerializedName("Accessories")
    @Expose
    private String accessories;
    @SerializedName("Stitched")
    @Expose
    private String stitched;

    public String getAccessories() {
        return accessories;
    }

    public void setAccessories(String accessories) {
        this.accessories = accessories;
    }

    public String getStitched() {
        return stitched;
    }

    public void setStitched(String stitched) {
        this.stitched = stitched;
    }
}