-1

I have this JSON structure:

{
    "A": 
    [
        {
            "B": "text",
            "C": "text",
            "D": 
            [
                {
                    "E": "text",
                    "F": ["text","text",...]
                }
            ]
        }
    ],  
    "G": 
        {
            "H": "text",
            "I": "text"
        }
}

Which is the correct java class for this structure? I've tried something but the response is null..

This is the javaBean for the JSON

public class Bean {
    private Response response;


    public Response getResponse() {
        return response;
    }

    public void setResponse(Response response) {
        this.response = response;
    }


    public static class Response {
        private List<A> a;
        private G g;

        public List<A> getA() {
            return a;
        }

        public void setA(List<A> a) {
            this.a = a;
        }

        public G getG() {
            return g;
        }

        public void setG(G g) {
            this.g = g;
        }
    }

    public static class A {
        private String b;
        private String c;
        private List<D> d;

        public List<D> getD() {
            return d;
        }

        public void setD(List<D> d) {
            this.d = d;
        }

        public String getB() {
            return b;
        }

        public void setB(String b) {
            this.b = b;
        }

        public String getC() {
            return c;
        }

        public void setC(String c) {
            this.c = c;
        }
    }

    public static class D {
        String e;
        List<String> f;

        public String getE() {
            return e;
        }

        public void setE(String e) {
            this.e = e;
        }

        public List<String> getF() {
            return f;
        }

        public void setF(List<String> f) {
            this.f = f;
        }
    }

     public static class G {
        private String H;
        private String I;

        public String getH() {
            return H;
        }

        public void setH(String H) {
            this.H = H;
        }

        public String getI() {
            return I;
        }

        public void setI(String I) {
            this.I = I;
        }
    }

}
nhaarman
  • 98,571
  • 55
  • 246
  • 278
Stefan
  • 145
  • 1
  • 1
  • 8

1 Answers1

0

try This one this will be work

ResponseBean.java

public class ResponseBean implement serializable {

@SerializedName("A")
public List<A> a;

@SerializedName("G")
public G g;

 public static class A {

    @SerializedName("B")
    private String b;

    @SerializedName("C")
    private String c;

    @SerializedName("D")
    private List<D> d;
}

public static class D {

    @SerializedName("E")
    private String e;

    @SerializedName("F")
    private F f;


}

public static class G {

    @SerializedName("H")
    private String h;

    @SerializedName("I")
    private String i;


}
public static class F {

    @SerializedName("Text")
    private String h;

    @SerializedName("Text")
    private String i;


}

}

bhavesh kaila
  • 761
  • 1
  • 5
  • 25
  • now it throws an exception java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING – Stefan Jul 08 '14 at 07:51