问答详情
源自:5-2 实现24小时天气预报查询功能

为啥代码是对的,还是有报错

Exception in thread "main" java.lang.RuntimeException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

at com.imooc.weather.impl.WeatherUtilsImpl.w24h(WeatherUtilsImpl.java:82)

at com.test.weather.Application.main(Application.java:22)

Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

at com.google.gson.Gson.fromJson(Gson.java:944)

at com.google.gson.Gson.fromJson(Gson.java:897)

at com.google.gson.Gson.fromJson(Gson.java:846)

at com.imooc.weather.impl.WeatherUtilsImpl.w24h(WeatherUtilsImpl.java:60)

... 1 more

Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:386)

at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:183)

at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)

at com.google.gson.Gson.fromJson(Gson.java:932)

... 4 more


提问者:慕码人4323451 2023-08-02 14:41

个回答