Conditional statement issue in product.json file / Trying to hide blank metafield

I have added this statment to my product.json file to hide blank metafields

“a2465fbd-ed30-43ec-b8a1-4116d9023fe9”: {
“type”: “text”,
“settings”: {
“text”: “{% if product.metafields.custom.dimensions.value != blank %}

Dimensions : {{ product.metafields.custom.dimensions.value }}

{% endif %}”
}
},

This is my error:

Unable to update the file

  • Setting ‘text’ can’t include Liquid syntax (‘{{’, ‘}}’, ‘{%’ or ‘%}’) without valid dynamic sources.

I have checked the JSON in https://codebeautify.org and it says its valid?

Any ideas please?

You can use type-liquid and “code”: key word as shown in the sample code below:

“type”: “liquid”,
“settings”: {
“code”: “{% if collection.title == "Kitchen" %}\n

Discount opportunity on modern and practical solutions for your kitchen!</p>\n {% endif %}\n\n{% if collection.title == "Bath" %}\n

Unmissable opportunities to add a modern touch to your bathroom!</p>\n {% endif %}”,
“width”: “100%”,
“alignment”: “center”
}