如何使用Gson将JSON转换为HashMap?
2022-08-31 05:04:00
						我正在从以 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模块。
 
					 
				 
				    		 
				    		 
				    		 
				    		