This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
Hello! I have created a Servlet that accesses the QueryBuilder API and outputs that data on a custom backend point, as you can see below.
The next step was to pull this JSON in from the Service we created into our Component, which I have set up as a JSONObject, though you are unable to loop through those in the htl. I have been trying to covert those from a JSONObject to a List so that we can loop through the results that we get from that QueryBuilder, but I haven't been able to get that converted correctly. Is there something that I am doing incorrectly on this? I'm not super well versed in Java, so I'm not sure if this is a silly mistake in my code or not.
Edit: removed code from 3rd parties
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @SocialTaylor ,
By looking at your code, Inner POJO class is not having Getters/Setters or public variables. So it won't be eligible for Serialization/Deserialization. and also your inner pojo class needs to be static for jackson serialization
So if you are using lombok dependency in your project, it has to be like below.
public static @Deleted Account class Page {
String path;
String title;
}
else
public static class Page {
String path;
String title;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
If I understood your questions correctly you want to loop through the "results" array in the JSON and print those value in a list in HTL i.e.,
path: some value
title: some title
path: some value
title: some tile
path: some value
title: some title
Let me know if my understanding is correct and I can help in getting the list.
Thanks!
Hello @Asutosh_Jena_ !
That would be correct. We'll be needing to create a component in which we can loop through Pages as Blog Posts so that we can create sort of a list of cards for users to have a preview and link out to the page itself!
Thanks for the reply again haha. You have been a huge help on this project!
By looking at your code, Inner POJO class is not having Getters/Setters or public variables. So it won't be eligible for Serialization/Deserialization. and also your inner POJO class needs to be static for jackson serialization.
So if you are using lombok dependency in your project, it has to be like below.
public static @Data class Page { String path; String title; }
else
public static class Page { String path; String title; public String getPath() { return path; } public void setPath(String path) { this.path = path; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } }
Hi @SocialTaylor ,
By looking at your code, Inner POJO class is not having Getters/Setters or public variables. So it won't be eligible for Serialization/Deserialization. and also your inner pojo class needs to be static for jackson serialization
So if you are using lombok dependency in your project, it has to be like below.
public static @Deleted Account class Page {
String path;
String title;
}
else
public static class Page {
String path;
String title;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
Views
Likes
Replies
Views
Likes
Replies