由于输入结束JSON解析器Play框架,没有要映射的内容

时间:2016-02-04 10:53:20

标签: java json http playframework postman

我有一个java play框架代码,其中我读取了通过Html请求体传递的json输入。

这是错误:

[RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
 at [Source: ; line: 1, column: 1]]

这是我的代码:

@BodyParser.Of(BodyParser.Json.class)
    public Result register() {
        JsonNode json = Json.parse(request().body().asJson().asText());
        ...

        response().setContentType("application/json");
        return ok(index.render( "{\"authToken\":\"" + userHelper.getToken() + "\"}"));
    }

发生错误的行是:

JsonNode json = Json.parse(request().body().asJson().asText());

这是我发送的json:

{"email":"something@something.something",
"password":"something",
"passwordConfirmation":"something",
"firstName":"something",
"lastName":"something",
"address":{
"streetName":"something",
"city":"something",
"country":"something"},
"phone":"something",
"gender":"something",
"birthdate":"something"}

我使用Postman发送PUT请求,并且我已将Content-type标头和Accept标头设置为application / json。我不知道为什么

0 个答案:

没有答案