我有简单的 Post 请求
POST /savings HTTP/1.1
Host: localhost:4567
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Body:
name=username&description=userdescription
我想知道如何将帖子正文转换name=username&description=userdescription
为 Json,例如:
{
"name": "username",
"description": "userdescription"
}
任何想法,我使用http://sparkjava.com,我需要处理内容类型的发布请求:application/x-www-form-urlencoded
post("/user", (request, response) -> {
// .. Convert request to User object
});