I am using spark to develop a small web application. I am coming off of using python's tornado framework, so a lot of this is new for me. I need to be able to serve json from the backend to the frontend. So, using their example, something like this.
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> {
return {
"foo" : "bar"
};
});
}
}
So to summarize, I want the ability to send a dictionary, a list, whatever is considered valid json to the frontend.
However, I understand that dicts/lists are not basic types in Java. Does anyone know how I could do this?
Take a look at the section Response Transformers at the documentation.