Freemarker: converting web content to Json object - liferay

in a Freemarker template I want to convert the entire web content data to a JSON object string without manually write all the structure fields.Is this possible?
Thank you very much,
Daniele.

You can get data in XML format by using the getContent method of JournalArticalLocalServiceUtil. but you could not get in JSON format directly.

Related

How to convert open api YAML structure to json

I want to make my UI to display all the information about the API.
Can you please tell me the best way to convert YAML structure to json?
Sometime i was also went through this issue and I solve them by using the online tools example : https://onlineyamltools.com/convert-yaml-to-json. that convert YAML structured file into JSON structured file .
but if you need a Javascript parser you can use js-yaml
you can use it to convert yaml to json with your js code.

Parsing a XML file and handling missing tags

I'm trying to parse a XML file in order to retrieve the data in a list.
I need to extract the TITRE_N, the AUTEURS_N and the RESUME_N. I know how to do it but my problem is that for some reference, I don't have any data for AUTEURS_N. there is no tag and the result as you can think it that all the data after are shift! Do you know how I can parse this doc and handle the fact that sometimes I'm missing one tag that I usefully use?
thx a lot!

Extract Excel data to transform to a simple XML

I am working on creating orders/receipts for a certain client that provides the data using Excel. However, it is not a common Excel table format but an actual form to be printed. I am having issues with the data mapper since it cannot be parsed correctly.
Is there a way to get the data so I can transform it to a simple XML?
I'm thinking if I can just get the data by declaring which column/row.
I can suggest you to use a custom transformer using Apache POI from XLS to a simple java POJO, then you can get your XML using the object-to-xml-transformer.
apache POI: https://poi.apache.org/spreadsheet/quick-guide.html#Iterator
object-to-xml-transformer:
https://docs.mulesoft.com/mule-user-guide/v/3.6/xmlobject-transformers

Exporting data from JSon

We are creating a map application that has a list view of the resultant set using JSON and jQuery and presenting the result to the user. How can we give the user the ability to download the result as an Excel file/CSV file?
Assuming a web application...
Convert JSON to CSV
Present It as an HTTP response.
You mentioned JSON and jQuery. I assume this is being used on the client side? There are a number of utilities for making the JSON-to-CSV conversion depending on the language you would want to use. Here are some examples.
Javascript/jQuery
PHP
Python

To upload an excel file as a clob

Could some one give an idea about how to convert an excel file into a CLOB in oracle through JDBC. I would like to know how to covert excel file into a String using API available as part of JDK and the conversion from string to clob should be straight forward. Thanks in advance. If a similar question was already raised, kindly provide me the link.
You will need a library out side of the standard java api to read a binary excel document.
You could use the JExcelApi to read in the Excel document then create a CSV String as you read in the document.
If you don't want to use an outside library then I would change the field type to blob and use the setBlob method of java.sql.PreparedStatment passing it a FileInputStream.
When you need to parse the data (read the contents) you can use a library like Apache POI
If you want to use the only standard API, then save the excel as CSV file and process the file as a comma seperated value list. That can easily be done with readline to read each line and split that line to values using the split method on a String.
If you do not need to parse data you should stream the data directly from file to a CLOB and not first transform the excel to a String
An example can be found here: http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
What is the representation of a spreadsheet in text format? The values indented by tabs? The formulas? What if you have more than one page in the xls file?
If what you really whant to do is to store the file in the database use a BLOB and store it as bytes.

Resources