我对休息骆驼组件的发布请求的正文不是 json 的形式。因此我无法提取键值对。如何将正文转换为 json?我发送了一个这种类型的 json 对象
{
"filename": "hello.txt",
"bucketName": "cameltry",
"accessKey": "key",
"secretKey": "key",
"region" : "us-east-1"
}
我必须使用这个 json 数据从 AWS S3 下载文件。骆驼中对应的路线是:
public static class HelloRoute extends RouteBuilder {
@Override
public void configure() {
rest("/")
.post("file-from-s3")
.route()
.setHeader(AWS2S3Constants.KEY, constant($body[filename]))
.toD("aws2-s3://${body[bucketName]}?accessKey=${body[accessKey]}&secretKey=${body[secretKey]}®ion=${body[region]}&operation=getObject")
.to("file:/tmp/")
.endRest();
}
这里$body[filename]
结果是 null 因为$body
不是 json 对象。如何将其转换为 json 对象?