I am trying to add a JSON-LD script through a component in HTML. I created an HTML file named productjson.html where I added the below script:
<sly data-sly-use.product="com.**.**.**.******.Product">
<script type="application/ld+json">{
"@context": "http://schema.org",
"@type": "Product",
"offers": "${product.offersjson}",
}
</script>
</sly>
Then, in the component's main HTML file, I included the productjson.html using the following tag:
<sly data-sly-include="productjson.html" />
output: in view page source in getting
<
ACTUAL:
"offers": [
{
"image": "https:/in_1.jpg",
,
"priceCurrency": "USD",
"price": 38,
},]
EXPECTED
"offers": [
{
"image": "https:/in_1.jpg",
"priceCurrency" :"usd"
"price" : "38"
},]
some decoding issue, if i try print that json in page it is getting properly from backend but in view page source " getting add
Solved! Go to Solution.
Views
Replies
Total Likes
Views
Replies
Total Likes
Thanks @Saravanan_Dharmaraj , now added it properly but
output is as below
ACTUAL:
"offers": [
{
"image": "https:/in_1.jpg",
,
"priceCurrency": "USD",
"price": 38,
},]
EXPECTED
"offers": [
{
"image": "https:/in_1.jpg",
"priceCurrency" :"usd"
"price" : "38"
},]
some decoding issue, from BE json is returning properly but in view page source issue is coming
Views
Replies
Total Likes
@user96222 please HTL context to render non html elements start with top and if none works use unsafe
https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md#121-display-context
Also in latest version sling introduced jsonstring context
Refer to Adobe core components example