为字符串列表添加JSON-LD

时间:2019-01-17 15:35:52

标签: json spring thymeleaf json-ld

我正在尝试使用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字符串数组?

0 个答案:

没有答案