Getting simple JSON object response using Retrofit library

后端 未结 8 2013
感动是毒
感动是毒 2020-12-17 17:59

I have a web query with JSON response as:

{
    \"status\":true,
    \"result\":
      {
        \"id\":\"1\",
        \"name\":\"ABC 1\",
        \"email\":         


        
相关标签:
8条回答
  • 2020-12-17 18:34

    Simply use JsonElement insted of JSONobject. Like:

    @GET("/stockers/login")
    Call<JsonElement> getLogin(
        @Query("email") String email,
        @Query("password") String password
    );
    
    0 讨论(0)
  • 2020-12-17 18:35

    Use JacksonConverterFactory instead of GsonConverterFactory while setting up Retrofit. Now you can directly work with JsonObject responses.

    compile 'com.squareup.retrofit2:converter-jackson:2.1.0'

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