在浏览器中点击 URI myresourceUrl 在浏览器中显示 json 内容。
要求:需要使用httpbuilder-ng的get方法调用URI的GET,response的内容为json。
此 json 文件将作为另一个任务的输入是必需的。如何实现这一点。我们是否需要任何解析器来使用 http-builder-ng 将返回的响应作为 json 获取。
预期响应格式:{"name":"Abc","info":{"age":45,"height":"5.5"}}
Tried the below get request using:
// setting the request URI
HttpBuilder http = HttpBuilder.configure(config -> {
config.getRequest().setUri(myresourceUrl);
});
String response = http.get(LazyMap.class, cfg -> {
cfg.getRequest().getUri().setPath(myPath);
}).toString();
我们得到的 实际格式:{name:Abc,info:{age:45,height:5.5}}
如何以预期的响应格式获得上述响应。