Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to display Blob /Json data field?
I am using service builder that is retrieving the form data fine from mysql db. I have a field that has the json data and I tried to map it using object mapper and using com.fasterxml.jackson.databind.ObjectMapper to display the json content. However the Blob Data is shown as : com.mysql.cj.jdbc.Blob@4ca74f7f
How do I actually get/extract the data from the storing link above? Here is my code snippet:
for (ddmcontent MyTemp : myList) {
System.out.println("Content ID :
"+myList.getContentId());
System.out.println("User Blob Data :
"+myList.getData());
Blob responseBody =myList.getData();
ObjectMapper objectMapper = new ObjectMapper();
List<ModelData> myDat = objectMapper.readValue((DataInput)
responseBody,objectMapper.getTypeFactory().constructCollectionType(List.class,ModelData.class));
for (ModelData dt : myDat) {
System.out.println("User Name :
"+dt.Name);
System.out.println("Users
Email : "+dt.Email);
}
}
Please note I have defined my ModelData elements as all String.
Any suggestion? What am I missing?
Thanks in advance!
Powered by Liferay™