Skip to main content
New Participant
February 28, 2023

how to convert entire html into json object?

  • February 28, 2023
  • 4 replies
  • 2053 views

Hi All,

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

Thankyou

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

DPrakashRaj
New Participant
March 1, 2023

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

Manu_Mathew_
New Participant
February 28, 2023

@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

 

dh54220Author
New Participant
March 1, 2023

@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.

TarunKumar
New Participant
February 28, 2023

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

dh54220Author
New Participant
March 1, 2023

@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.

krishna_sai
New Participant
February 28, 2023

@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-sling-model-exporter.html?lang=en

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

Hope this helps,

Krishna

dh54220Author
New Participant
March 1, 2023

@krishna_sai 

Thank you for the reply

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