|
2 | 2 |
|
3 | 3 | import com.google.common.base.Joiner; |
4 | 4 | import com.google.gson.JsonArray; |
5 | | -import com.google.gson.JsonElement; |
6 | 5 | import com.google.gson.JsonObject; |
7 | | -import com.google.gson.JsonParser; |
8 | 6 | import lombok.extern.slf4j.Slf4j; |
9 | 7 | import me.chanjar.weixin.common.WxType; |
10 | 8 | import me.chanjar.weixin.common.bean.WxJsapiSignature; |
|
20 | 18 | import me.chanjar.weixin.common.util.http.RequestHttp; |
21 | 19 | import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; |
22 | 20 | import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; |
| 21 | +import me.chanjar.weixin.common.util.json.GsonParser; |
23 | 22 | import me.chanjar.weixin.cp.api.*; |
24 | 23 | import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; |
25 | 24 | import me.chanjar.weixin.cp.bean.WxCpMessage; |
@@ -110,7 +109,7 @@ public String getAgentJsapiTicket(boolean forceRefresh) throws WxErrorException |
110 | 109 | synchronized (this.globalAgentJsapiTicketRefreshLock) { |
111 | 110 | if (this.configStorage.isAgentJsapiTicketExpired()) { |
112 | 111 | String responseContent = this.get(this.configStorage.getApiUrl(GET_AGENT_CONFIG_TICKET), null); |
113 | | - JsonObject jsonObject = new JsonParser().parse(responseContent).getAsJsonObject(); |
| 112 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
114 | 113 | this.configStorage.updateAgentJsapiTicket(jsonObject.get("ticket").getAsString(), |
115 | 114 | jsonObject.get("expires_in").getAsInt()); |
116 | 115 | } |
@@ -135,7 +134,7 @@ public String getJsapiTicket(boolean forceRefresh) throws WxErrorException { |
135 | 134 | synchronized (this.globalJsapiTicketRefreshLock) { |
136 | 135 | if (this.configStorage.isJsapiTicketExpired()) { |
137 | 136 | String responseContent = this.get(this.configStorage.getApiUrl(GET_JSAPI_TICKET), null); |
138 | | - JsonObject tmpJsonObject = new JsonParser().parse(responseContent).getAsJsonObject(); |
| 137 | + JsonObject tmpJsonObject = GsonParser.parse(responseContent); |
139 | 138 | this.configStorage.updateJsapiTicket(tmpJsonObject.get("ticket").getAsString(), |
140 | 139 | tmpJsonObject.get("expires_in").getAsInt()); |
141 | 140 | } |
@@ -191,8 +190,8 @@ public WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorEx |
191 | 190 | @Override |
192 | 191 | public String[] getCallbackIp() throws WxErrorException { |
193 | 192 | String responseContent = get(this.configStorage.getApiUrl(GET_CALLBACK_IP), null); |
194 | | - JsonElement tmpJsonElement = new JsonParser().parse(responseContent); |
195 | | - JsonArray jsonArray = tmpJsonElement.getAsJsonObject().get("ip_list").getAsJsonArray(); |
| 193 | + JsonObject tmpJsonObject = GsonParser.parse(responseContent); |
| 194 | + JsonArray jsonArray = tmpJsonObject.get("ip_list").getAsJsonArray(); |
196 | 195 | String[] ips = new String[jsonArray.size()]; |
197 | 196 | for (int i = 0; i < jsonArray.size(); i++) { |
198 | 197 | ips[i] = jsonArray.get(i).getAsString(); |
|