Adding JSON-LD for a list of strings

Viewed 151

I'm trying to use Thymeleaf to output a list of strings for the ingredient field of my JSON-LD. In my controller I have recipe.ingredients which is a ArrayList<String>.

My code:

<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}} ]],

        }

Ingredient is output in the generated JSON-LD as (missing quotes around each element):

"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],

How can I get a proper JSON array of strings from the List<String> in the model?

0 Answers
Related