私は改装を使用して無料の辞書apiを使用してオンライン辞書を作ろうとしています 私はretrofitで新しくなりました。私はいつでもアプリを実行しています。オンライン辞典apiは改造を使用していません
Logcatエラー:
com.google.gson.stream.MalformedJsonException:使用 JsonReader.setLenient(真の)ラインで不正な形式のJSONを受け入れるように1列 1つのパス$ 07-03 16: 17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err: com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1567) 07-03 16:17:38.531 25440- 25479/com.mohit.dictionaryapp W/System.err:
at com.google.gson.stream.JsonR (JsonReader.java:1416) 07-03 16:17:38.531 .java:597)07-03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err: com.google.gson.stream.JsonReader.peek(JsonReader.java:429)07 -03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err: com.google.gson.internal.bind.CollectionTypeAdapterFactory $ Adapter.read(CollectionTypeAdapterFactory.java:74) 07- 03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err:
at com.google.gson.internal.bind.CollectionTypeAdapterFactory $ Adapter.read(CollectionTypeAdapt erFactory.java:61) 07-03 16:17:38.531 25440から25479/com.mohit.dictionaryapp W/System.errの: retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37で
) 07-03 16:17:38.531 25440から25479/com.mohit.dictionaryappのW/System.errの: retrofit2.converter.gson.GsonResponseBodyConverter.convertで
(GsonResponseBodyConverter.java:25) 07-03 16。 17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err:
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:116)07-03 16:17:38.531 25440-25479/com.mohit。辞書アプリケーションW/System.err: retrofit2.OkHttpCall.parseResponse(OkH ttpCall.java:211)07-03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err: retrofit2.OkHttpCall.execute(OkHttpCall.java:174)07-03 16:17 :38.531 25440-25479/com.mohit.dictionaryapp W/System.err: retrofit2.ExecutorCallAdapterFactory $ ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:89) 07-03 16:17:38.531 25440-25479/com.mohit .dictionaryapp W/System.err:
( )com.mohit.dictionaryapp.DictionaryApi.searchMeaning(DictionaryApi.java:33) 07-03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System。エラー:
at com.mohit.dictionaryapp.GetMeaningTask.doInBackground(GetMeaningTask.java:27) 07-03 16:17:38.531 25440から25479/com.mohit.dictionaryapp W/System.errの: com.mohit.dictionaryapp.GetMeaningTask.doInBackground(GetMeaningTask.java:13)で
07-03 16。 17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err:
android.os.AsyncTask $ 2.call(AsyncTask.java:288)07-03 16:17:38.531 25440-25479/com .mohit.dictionaryapp W/System.err: でjava.util.concurrent.FutureTask.run(FutureTask。java:237)07-03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err: android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)07-03 16:17:38.531 25440-25479/com.mohit.dictionaryapp W/System.err: java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 07-03 16:17:38.532 25440- 25479/com.mohit.dictionaryapp W/System.err:
java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587) 07-03 16:17:38.532 25440-25479/com。 mohit.dictionaryapp W/System.err:
at java.lang.Thread.run(Thread.java:818)
DictionaryApi.java
public class DictionaryApi {
public interface Alfa{
@GET("/word.json/{word}/definitions")
Call<ArrayList<Dictionary>> meaning(@Path("word") String word,@Query("api_key") String api_key);
}
public static ArrayList<Dictionary> searchMeaning(String word,String api_key){
Retrofit retrofit=new Retrofit.Builder().baseUrl("http://api.wordnik.com/v4/")
.addConverterFactory(GsonConverterFactory.create()).build();
Alfa alfa=retrofit.create(Alfa.class);
Call<ArrayList<Dictionary>> call = alfa.meaning(word,api_key);
try {
Response<ArrayList<Dictionary>> response=call.execute();
Log.e("Dpi", response.message().toString());
Log.e("Dpi",String.valueOf(response.code()));
return response.body();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
Dictionary.java(POJO)
public class Dictionary {
public String word;
public String partOfSpeech;
public String sequence;
public String text;
}
は、この問題を解決するために私を助けてください。 JSONレスポンスから
"?"要求に含まれます。 Retrofitはクエリパラメータを管理します。 –
いいえ、それはうまくいきませんでした...それも試しました... –
あなたのレトロフィットデバッグログを表示できますか? –