【发布时间】:2020-08-18 10:50:23
【问题描述】:
我想在 JSON 响应中生成带有 URI 的 JSON,但是当我尝试获取键的值时出现 JSON 异常。这里的 fragmentdataservice 用于获取 JSON 数据,它工作正常,我正在使用内容片段创建 API。
String requestURI = req.getRequestURI();
String contentFragmentName = requestURI.substring(requestURI.indexOf('.') +
1, requestURI.lastIndexOf('.'));
resp.setContentType("application/json");
response = fragmentDataService.getContentFragment(contentFragmentName);
String contentReference = response.getJSONObject("poolingInfo").toString();
JSONObject contentData = fragmentDataService.getContentFragment(contentReference);
response.put("poolingInfo", contentData);
【问题讨论】:
-
您遇到了什么异常?您确定响应是有效的 JSON 文档吗?
标签: java json api content-management-system aem