This website uses cookies to ensure you get the best experience. Learn More.
Conversion of Web-Content’s XML to JSON
In some of the project, I have seen the requirements to convert web-content’s xml into JSON format to expose their web-content related API to 3rd party or perform some operation on data/manipulate data. I know you will be thinking that we can use Liferay's jsonws to fetch the web-content in JSON format but still you will get article content in xml format.
To achieve this, I have written 1 utility which will convert your web-content xml data into JSON format.
Please see the below code snippet to convert web-content XML to JSON
FetchNode method to fetch the nodes and convert into JSON
Fetch the child Node and convert into an Array
Fetch the child node and convert into Json Object
Convert the node to nodeMap which contain the node name and node value