Solved

What is the proper way to convert the JSON RTE to HTML and/or back to JSON?

  • 19 April 2022
  • 1 reply
  • 309 views

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

Best answer by nick.nguyen 28 April 2022, 00:08

View original

1 reply

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.

  1. entry: result from entry JSON response
  2. paths: can be array list of paths to json.rte's or reference json.rte's. For example: ["json_rte", "reference.json_rte"]
  3. 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