现在是:2022年4月30日22:29:49
大家好,我是雄雄。
刚刚在调用接口的时候,出现了个错误:
{
"code": 400,
"success": false,
"data": null,
"msg": "JSON parse error: Unexpected character ('1' (code 49)): was expecting a colon to separate field name and value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('1' (code 49)): was expecting a colon to separate field name and value\n at [Source: (PushbackInputStream); line: 1, column: 67]"
}
我的后台代码是这样的:
@PostMapping("/updateProjectBeginTime")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "threePlant-第一个动作的更新", notes = "传入userId,programmeId,projectId,time")
public R updateProjectBeginTime(@ApiParam(value = "训练方案业务对象", required = true) @RequestBody TrainingVO trainingVO) {
//第一个动作的开始时间
trainingVO.setBeginTime(trainingVO.getTime());
//第一个动作:训练中
trainingVO.setStatus(1);
//将第一个动作放在redis的缓存中
bladeRedis.set("training:updateTrainingStatusAndTime:" +
trainingVO.getUserId() + ":" +
trainingVO.getProgrammeId(), trainingVO.getProjectId());
//调用更新的借口
return trainingSchemeUrlService.updateTrainingProgrammeAndProjectStatusAndTime(trainingVO);
}
这是我的传参:
{
"projectId":4336,
"userId":1520262094935859201,
"time"1651327242254:,
"programmeId":400
}
乍一看都对,但是调用的时候就是调不通,还报了个上面的错,于是我就在网上搜啊搜啊,长篇大论一堆,都没有解决。
然后我就仔细分析,看报错应该是json
的问题,但是json
能有啥问题呢。检查传参,终于发现问题了。
是我的time参数传参的时候格式不对…
错误的格式:
"time"1651327242254:,
正确的格式:
"time":1651327242254,
改过来就可以啦,一定要仔细,细心!