G
G
gleb2702018-06-17 17:29:37
Java
gleb270, 2018-06-17 17:29:37

Why can the characters in the server response change?

spoiler
Nan_ersDPB4.jpg04lM1J4WCa0.jpg

The server sends a json string, why a different option may come to the phone (without quotes with the replacement : with =), in the code
interface GetInfo {
        @GET("{url}")
        Call<Object> getData(@Path("url") String url);
    }

final TextView tt=findViewById(R.id.tt);
            final String server = "https://rest-fns-check.herokuapp.com/check/";
            final Gson gson = new GsonBuilder().create();
            Retrofit retrofit = new Retrofit.Builder()
                    .addConverterFactory(GsonConverterFactory.create(gson))
                    .baseUrl(server)
                    .build();
            GetInfo info = retrofit.create(GetInfo.class);
            Call<Object> call = info.getData(address);
            call.enqueue(new Callback<Object>() {
                @Override
                public void onResponse(Call<Object> call, Response<Object> response) {
                    tt.setText(response.body().toString());//map.get("raw_response"));
                }

                @Override
                public void onFailure(Call<Object> call, Throwable t) {
                }
            });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Varakosov, 2018-06-18
@gleb270

body().toString() returns a beautified JSON. Of course, : will be replaced by =.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question