
com.github.gkutiel.result.Json Maven / Gradle / Ivy
The newest version!
package com.github.gkutiel.result;
import java.util.function.Supplier;
import com.google.gson.Gson;
public class Json extends Textual {
public static Json json(final Supplier obj) {
return json(obj.get());
}
public static Json json(final T obj) {
return new Json(obj);
}
private static final Gson gson = new Gson();
private final T obj;
private Json(final T obj) {
this.obj = obj;
}
@Override protected String getContentType() {
return "application/json";
}
@Override protected String getText() {
return gson.toJson(obj);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy