Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get json array response in retrofit

    @FormUrlEncoded
    @POST("api/sponsors")
    Call<List<SponsorsResult>> getStatesAndDistrict(
            @Field("xyz") String field1
    );



   Call <List<SponsorsResult>> call = service.getSponsorsValue();

    call.enqueue(new Callback<List<SponsorsResult>>() {
        @Override
        public void onResponse(Call<List<SponsorsResult>> call, Response<List<SponsorsResult>> response) {

            List<SponsorsResult> rs = response.body();

        }

        @Override
        public void onFailure(Call<List<SponsorsResult>> call, Throwable t) {

        }
    });



 class SponsorsResult {

    @SerializedName("sponsors")
    private List<SponsorsValue> sponsors;

    public List<SponsorsValue> getSponsors() {
        return sponsors;
    }
}

class SponsorsValue{
    @SerializedName("leg_id")
    @Expose
    private String legId;
    @SerializedName("type")
    @Expose
    private String type;
    @SerializedName("name")
    @Expose
    private String name;

    public String getLegId() {
        return legId;
    }

    public void setLegId(String legId) {
        this.legId = legId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
Comment

how to get json array response in retrofit

@FormUrlEncoded
    @POST("api/sponsors")
    Call<List<SponsorsResult>> getStatesAndDistrict(
            @Field("xyz") String field1
    );



   Call <List<SponsorsResult>> call = service.getSponsorsValue();

    call.enqueue(new Callback<List<SponsorsResult>>() {
        @Override
        public void onResponse(Call<List<SponsorsResult>> call, Response<List<SponsorsResult>> response) {

            List<SponsorsResult> rs = response.body();

        }

        @Override
        public void onFailure(Call<List<SponsorsResult>> call, Throwable t) {

        }
    });
Comment

PREVIOUS NEXT
Code Example
Javascript :: URLSearchParams 
Javascript :: text input underline react native 
Javascript :: check contect type axios response 
Javascript :: javascript function add two numbers 
Javascript :: simple express server 
Javascript :: jquery get name value method 
Javascript :: javascript on focus 
Javascript :: how to make javascript function consise 
Javascript :: hide html elements 
Javascript :: Updating javascript object property 
Javascript :: send params in nested screen 
Javascript :: find element causing vertical overflow 
Javascript :: Expresion regular para validar Dirección URL 
Javascript :: round value down html 
Javascript :: vue 3 
Javascript :: how to append element in array angular 
Javascript :: append item in treeview vuetify 
Javascript :: check if alpine js is activated in website 
Javascript :: strupper in js 
Javascript :: parentnode javascript 
Javascript :: three dots in javascript 
Javascript :: selialize jquery 
Javascript :: jquery slider get value on change 
Javascript :: spread operator react 
Javascript :: How to use await with map in js 
Javascript :: datatables buttons do not appear localisation 
Javascript :: how to trim the file name when length more than 10 in angular 
Javascript :: modal react form table 
Javascript :: discord.js find word inside comment 
Javascript :: console log javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =