Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

how to convert entire html into json object?

Avatar

Level 3

Hi All,

we have a footer experience fragment how we can convert entire html page as json object
any references 

Thankyou

7 Replies

Avatar

Community Advisor

@dh54220 If the components that you are using in experience fragments have exporter support i.e., annotated with exporter.
https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/develop-slin...

you can simply add .model.json  to your experience fragment which will give you json structure

Hope this helps,

Krishna

Avatar

Level 3

@krishna_sai 

Thank you for the reply

I need not only json entire html as json object (include css and js)
any suggestion.?

 

Avatar

Community Advisor

HI @dh54220 ,

Experience fragment are delivered in HTML format by default.
However, if you are creating experience fragment with core components or develop your custom components using ComponentExporter, it should provide all the content in JSON format.
Hope this help!

Thanks

Avatar

Level 3

@TarunKumar 

Thank you for the reply

Experience fragment are delivered in HTML format by default( can please brief on this)

 we have requirement that we have header and footer experience fragment we need to send the entire html as json object(with include css and js) how we can achieve any suggestion.

Avatar

Community Advisor

@dh54220 You can just replace the .html with .model.tidy.json  similar to the sample wnkd site eg: .../content/wknd/language-masters/en/magazine.model.tidy.json

 

Avatar

Level 3

@Manu_Mathew_ 

Thankyou for the reply

we use of tidy.json we can convert json in readable format right?

what is my question is actually we have requirement that we have header and footer experience fragment we need to send the entire html as json object(with include css andjs) how we can achieve any suggestion.

Avatar

Community Advisor

to export the data as json including js and css you have to write your custom service either using sling model exporter.