解析数组列表包含整数和字符串的ArrayList

时间:2017-10-15 08:41:05

标签: android json

Response from Webservice using retrofit2, how to parse this data to a model call and returns the data in proper way

    JobsInterface jobsInterface= ApiClient.createService(JobsInterface.class,context);
    /*Call<String> stringCall=jobsInterface.getJobsData("data1,"data2",usernames,passwords,data5);*/
    Call<ArrayList<Integer>> stringCall=jobsInterface.getJobsData(url);
    stringCall.enqueue(new Callback<ArrayList<Integer>>() {
        @Override
        public void onResponse(Call<ArrayList<Integer>> call, Response<ArrayList<Integer>> response) {
            mProgress.dismiss();
            String data= response.errorBody().toString();
            String dss=response.message().toString();
            String dssd=response.raw().toString();
        }

        @Override
        public void onFailure(Call<ArrayList<Integer>> call, Throwable t) {
            mProgress.dismiss();
        }
    });
}
    @GET
Call<ArrayList<Integer>> getJobsData(@Url String url);
    public class ApiClient {


private static Retrofit retrofit;

private static Context contextt;
private static boolean loginFalg = false;

private static  String URL;

private static HttpLoggingInterceptor interceptor
        = new HttpLoggingInterceptor()
        .setLevel(HttpLoggingInterceptor.Level.BODY); // for logging and debugging

private static  CookieHandler cookieHandler = new CookieManager();
private static OkHttpClient.Builder httpClientBuilder
        = new OkHttpClient.Builder()
        .cookieJar(new JavaNetCookieJar(cookieHandler))
        .connectTimeout(30, TimeUnit.SECONDS)
        .readTimeout(60,TimeUnit.SECONDS)
        .addInterceptor(interceptor);

private static Gson gson = new GsonBuilder()
        .setLenient()
        .create();
private static Retrofit.Builder builder =
        new Retrofit.Builder()
                .baseUrl("http://localhost/")
                .addConverterFactory(GsonConverterFactory.create(gson));

public static <S> S createService(Class<S> serviceClass, Context context) {
    /*OkHttpClient okHttpClient=getUnsafeOkHttpClient();*/


    contextt = context;
    retrofit = builder
            .client(httpClientBuilder.build())
            .build();
    return retrofit.create(serviceClass);

}
}

how to parse these data to a model call, so that I can apply to Call> 我收到错误java.lang.IllegalStateException:预期BEGIN_ARRAY但在第7行第2行路径为STRING

我的JSON格式是

               [
[

    {
        "0": "Utilities on",
        "1": "Utilities on",
        "dd": "Utilities on",
        "freqitem": "Utilities on"
    },
    {
        "0": "Vacant",
        "1": "Vacant",
        "dd": "Vacant",
        "freqitem": "Vacant"
    }
],
[

    {
        "0": "62",
        "1": "9a-INDIVIDUAL SUBPOE",
        "mannerid": "62",
        "manner": "9a-INDIVIDUAL SUBPOE"
    },
    {
        "0": "67",
        "1": "9a-NON SERVICE SUBPO",
        "mannerid": "67",
        "manner": "9a-NON SERVICE SUBPO"
    }
],
null,
[

    {
        "0": "19",
        "1": "GRANDMOTHER",
        "sid": "19",
        "stitle": "GRANDMOTHER"
    },
    {
        "0": "5",
        "1": "HUSBAND",
        "sid": "5",
        "stitle": "HUSBAND"
    }
],
[
    "Female",
    "Male",
    "N/A",
    "Unknown"

],
[
    "1",
    "1",
    "1",
    "1",
    "2",
    "2"

],
[
    {
        "0": "7",
        "1": "test",
        "2": "anm",
        "3": "test plaintiff b & asdf"

    },
    {
        "0": "61",
        "1": "test",
        "2": "anm",
        "3": "TEST PLAINTIFF1"

    }
],
[
    {
        "0": "7",
        "1": "1",
        "2": "addr",
        "3": "addr1",
        "4": "some add",
        "5": "NY",
        "6": "12313",
        "7": "",
        "8": ""

    },
    {
        "0": "15",
        "1": "1",
        "2": "1245 TEST AVENUE",
        "3": "",
        "4": "Saint Albans",
        "5": "NY",
        "6": "11412",
        "7": "",
        "8": ""

    }
]
]

1 个答案:

答案 0 :(得分:0)

[[(字典)]]

或者

阵列(阵列(字典))

array -...中array-againe字典内的数组 你应该以这种方式写登录。