public JSONObject newQueryTradeRuleInformationJSONObject param String result = SenderUtils sendDataWithRetryparamtoJSONString SystemParamInitgetQueryHSRateUrl
根据错误信息,报错是由于JSON解析出现了语法错误导致的。可以尝试以下修改:
- 检查
param.toJSONString()方法返回的JSON字符串是否正确,确保其格式是正确的JSON格式。 - 检查
Base64util.decode(result)方法返回的字符串是否正确,确保其是经过Base64编码的字符串。 - 可以尝试使用
try-catch块来捕获JSON解析异常,并进行相应的处理,例如打印错误信息或返回默认的JSONObject对象。
修改后的代码如下:
public JSONObject newQueryTradeRuleInformation(JSONObject param) {
try {
String result = SenderUtils
.sendDataWithRetry(param.toJSONString(), SystemParamInit.getQueryHSRateUrl(),
null);
logger.info("查询工具税率接口返回结果:" + JSON.toJSONString(Base64util.decode(result)));
return JSONObject.parseObject(Base64util.decode(result));
} catch (com.alibaba.fastjson.JSONException e) {
logger.error("JSON解析出现异常:" + e.getMessage());
return new JSONObject(); // 返回一个默认的空JSONObject对象
}
}
这样修改后,如果JSON解析出现异常,将会打印错误信息并返回一个空的JSONObject对象
原文地址: https://www.cveoy.top/t/topic/ixcT 著作权归作者所有。请勿转载和采集!