从multiFiledq取到的JSON字符串如下 { “hero_name”: “Perficient Trusted to Deliver DPA”, “hero_picture”: “/content/dam/PeficientDigit/hero-insights-lg.jpg”, “hero_tip”: “Named a “Strong Performer” in the Forrester Wave”, “hero_button_text”: “See Why”, “hero_button_url”: “https://www.baidu.com/” }, { “hero_name”: “Your Brand is Made of Moments”, “hero_picture”: “/content/dam/PeficientDigit/hero-pd-banners-4.jpg”, “hero_tip”: “Because great brands are the sum of every great customer moment.”, “hero_button_text”: “Learn More About Perficient Digital”, “hero_button_url”: “https://www.perficientdigital.com/” }
HTL代码
<input type="hidden" id="str1" value=${properties.hero_block} />
<script>
var json_txt=document.getElementById("str1").value;
var str_obj="{ \"hero_block\" : [" +json_txt+ "]}";
console.log(str_obj);
var obj = eval ("(" + str_obj + ")");
console.log(json_txt);
alert(obj.hero_block[0].hero_name);
</script>