java-tutorials/play-framework/introduction/app/util/Util.java

17 lines
500 B
Java
Raw Normal View History

package util;
2016-10-04 11:54:59 -04:00
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import play.libs.Json;
2016-10-04 11:54:59 -04:00
public class Util {
public static ObjectNode createResponse(Object response, boolean ok) {
ObjectNode result = Json.newObject();
result.put("isSuccessfull", ok);
if (response instanceof String)
result.put("body", (String) response);
else result.put("body", (JsonNode) response);
2016-10-04 11:54:59 -04:00
return result;
}
}