我正在尝试解析以下JSON以在网页上以表格格式显示信息,如下图所示。我通过使用ObjectMapper将JSON字符串转换为对象,然后将其添加到网页模型来实现此目的。我想知道是否有任何方法可以在不使用Object Mapper的情况下直接将JSON字符串解析为Thymeleaf?
JSON字符串
{
"kernelVersion": "4.4.0",
"videoAppVersion": "1.2.3",
"zigbeeAppVersion": "1.2",
"overrideFiles": [{
"path": "/0/21/gateway.conf",
"sizeBytes": 0
}, {
"path": "/1/21/gateway2.conf",
"sizeBytes": 2
}, {
"path": "/2/21/gateway2.conf",
"sizeBytes": 2
}],
"sshKeyVersion": "ZA-1515092259"
}
表diaply的HTML代码
<table>
<tr>
<td><label>Camera Name</label></td>
<td th:text="${cameraDetails.cameraInfo.cameraName}">10.103.3.120</td>
</tr>
.......
<tr>
<td><label>Override files</label></td>
<td>
<table style="width:100%; margin-left: 0px;">
<tr>
<td> <label>File Path</label></td>
<td><label> File Size</label></td>
</tr>
<tr th:each="overrideFile : ${cameraDetails.cameraInfo.overrideFiles}">
<td th:text="${overrideFile.path}">001</td>
<td th:text="${overrideFile.sizeBytes}">001</td>
</tr>
</table>
</td>
</tr>
</table>