Best answer by nick.nguyen
View originalWhat is the proper way to convert the JSON RTE to HTML and/or back to JSON?
Userlevel 4
What is the most efficient way to convert the JSON RTE to HTML, and back to JSON if needed?
A simple use case is when a developer needs the JSON to render flat to HTML for display purposes.
Userlevel 4
There are 2 ways natively to do this. You can choose either of the following.
1. Utils Documentation - The utils package is great to convert JSON to HTML. With this package you can also specify how different elements (<a>, <href>, <p>, <span>, etc) are styled, by passing in different arguments. The arguments follow the structure below.
- entry: result from entry JSON response
- paths: can be array list of paths to json.rte's or reference json.rte's. For example: ["json_rte", "reference.json_rte"]
- renderOption: format options for each type of dom element you may want to custom render.
2. json-rte-Serializer - This is a standalone node library to convert from JSON → HTML and HTML → JSON.
Reply
Login to the community
No account yet? Create an account
Contentstack Login
Log in with Contentstackor
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.