我正在创建一个Android应用程序,显示它从在线API获得的json格式的天气数据。为此,我使用了GSON图书馆。
我有以下JSON字符串,我从地图对象中获取:
{id=800, main=Clear, description=clear sky, icon=01n}
它包含以下值:
Map weatherMap = new Gson().fromJson(weather, Map.class);
但是当我尝试使用该字符串创建另一个Map对象时,我得到了一个异常。
{temp=277.15, pressure=1021, humidity=80, temp_min=277.15, temp_max=277.15}
异常logcat报告:
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException:未终止的对象at 第1栏第43栏
我很困惑,因为我已尝试使用另一个json字符串,如下所示,它运行得很好:
{{1}}
答案 0 :(得分:1)
字符串必须在双引号之间
{id=800, main="Clear", description="clear sky", icon=01n}