PingPlusPlus/pingpp-java

请求体解析失败: 不是一个合法的 json 格式字符串

Closed this issue · 0 comments

直接复制官网给出的示例代码,使用gradle引入sdk后,Charge.create一直调试不通,给出异常信息如下:

com.pingplusplus.exception.InvalidRequestException: Error type: invalid_request_error
Error message: 请求体解析失败: 不是一个合法的 json 格式字符串

at com.pingplusplus.net.APIResource.handleAPIError(Unknown Source)
at com.pingplusplus.net.APIResource.request(Unknown Source)
at com.pingplusplus.model.Charge.create(Unknown Source)

跟踪调试发现,APIResource.createJSONString一直返回null

https://github.com/PingPlusPlus/pingpp-java/blob/master/src/main/java/com/pingplusplus/net/APIResource.java#L527

//sdk中序列化部分代码
Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
logger.debug(gson.toJson(chargeParams)); //输出null

logger.debug(JSONUtils.toJson(chargeParams));
//输出:{"order_no":"1bo6u5e010001","app":{"id":"adfaadfasdfads"},"amount":100,"subject":"adfadf","channel":"alipay","client_ip":"127.0.0.1","currency":"cny","body":"1bo9mv9010001"}

烦请确认!
`