我正在从服务器请求数据,该服务器以 JSON 格式返回数据。在发出请求时将 HashMap 转换为 JSON 一点也不难,但另一种方式似乎有点棘手。 JSON 响应如下所示:
{
"header" : {
"alerts" : [
{
"AlertID" : "2",
"TSExpires" : null,
"Target" : "1",
"Text" : "woot",
"Type" : "1"
},
{
"AlertID" : "3",
"TSExpires" : null,
"Target" : "1",
"Text" : "woot",
"Type" : "1"
}
],
"session" : "0bc8d0835f93ac3ebbf11560b2c5be9a"
},
"result" : "4be26bc400d3c"
}
哪种方式最容易访问这些数据?我正在使用 GSON 模块。
原文由 Mridang Agarwalla 发布,翻译遵循 CC BY-SA 4.0 许可协议
干得好: