我正在尝试使用Thymeleaf为我的JSON-LD的成分字段输出字符串列表。在我的控制器中,我有一个{。{1}}的recipe.ingredients。
我的代码:
ArrayList<String>
成分在生成的JSON-LD中输出为(每个元素周围缺少引号):
<script type="application/ld+json" th:inline="text">
{
"@context": "http://schema.org",
"@type": "Recipe",
"author": "",
"name": "[[ @{${item.name}} ]]",
"description": "[[ @{${item.shortDesc}} ]]",
"image": "[[ @{${item.image}} ]]",
"ingredients": [[ @{${recipe.ingredients}} ]],
}
如何从模型中的"ingredients": [2 eggs, 3 tbs almond flour, 1 tbs butter, 1/2 tsp baking powder, 2 pieces cooked bacon, 1 slice american cheese, Everything but the bagel seasoning],
获取正确的JSON字符串数组?