本文整理了Java中play.libs.Json.toJson()
方法的一些代码示例,展示了Json.toJson()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.toJson()
方法的具体详情如下:
包路径:play.libs.Json
类名称:Json
方法名:toJson
[英]Converts an object to JsonNode.
[中]将对象转换为JsonNode。
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play
private Result listSessions() {
List<String> list = new ArrayList<>(knownSessionIDs.keySet());
if (uploadedFileLines != null) {
list.add(UPLOADED_FILE);
}
return Results.ok(Json.toJson(list));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
private Result listSessions() {
List<String> list = new ArrayList<>(knownSessionIDs.keySet());
if (uploadedFileLines != null) {
list.add(UPLOADED_FILE);
}
return Results.ok(Json.toJson(list));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.11
private Result listSessions() {
List<String> list = new ArrayList<>(knownSessionIDs.keySet());
if (uploadedFileLines != null) {
list.add(UPLOADED_FILE);
}
return Results.ok(Json.toJson(list));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
private Result listSessions() {
return ok(Json.toJson(knownSessionIDs.keySet()));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
private Result listSessions() {
return Results.ok(Json.toJson(knownSessionIDs.keySet()));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
private Result getCoords(String sessionId) {
if (UPLOADED_FILE.equals(sessionId) && uploadedFileLines != null) {
return Results.ok(Json.toJson(uploadedFileLines));
} else if (knownSessionIDs.containsKey(sessionId)) {
return Results.ok(Json.toJson(knownSessionIDs.get(sessionId)));
} else {
return Results.ok();
}
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play
private Result getCoords(String sessionId) {
if (UPLOADED_FILE.equals(sessionId) && uploadedFileLines != null) {
return Results.ok(Json.toJson(uploadedFileLines));
} else if (knownSessionIDs.containsKey(sessionId)) {
return Results.ok(Json.toJson(knownSessionIDs.get(sessionId)));
} else {
return Results.ok();
}
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.11
private Result getCoords(String sessionId) {
if (UPLOADED_FILE.equals(sessionId) && uploadedFileLines != null) {
return Results.ok(Json.toJson(uploadedFileLines));
} else if (knownSessionIDs.containsKey(sessionId)) {
return Results.ok(Json.toJson(knownSessionIDs.get(sessionId)));
} else {
return Results.ok();
}
}
代码示例来源:origin: uk.gov.hmrc/microservice-bootstrap-java
private JsonNode createJsonResponse(ConstraintViolationException cex) {
Map<String, List<String>> validationMessages = Optional
.fromNullable(cex.getConstraintViolations())
.or(new HashSet<>())
.stream()
.map(v -> new F.Tuple<>(v.getPropertyPath().toString(), v.getMessage()))
.collect(groupingBy(t -> t._1, mapping(t -> t._2, toList())));
return toJson(validationMessages);
}
代码示例来源:origin: org.deeplearning4j/arbiter-ui
/**
* @return Last update time for the page
*/
private Result getLastUpdateTime(){
//TODO - this forces updates on every request... which is fine, just inefficient
long t = System.currentTimeMillis();
UpdateStatus us = new UpdateStatus(t, t, t);
return ok(Json.toJson(us));
}
代码示例来源:origin: com.commercetools.sunrise/common
/**
* {@inheritDoc}
*/
@Override
public <U> void overwriteObjectByKey(final String key, final U object) {
final JsonNode jsonNode = Json.toJson(object);
final String valueAsJson = Json.stringify(jsonNode);
overwriteValueByKey(key, valueAsJson);
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
private Result getStaticInfo(String sessionID) {
if (!knownSessionIDs.containsKey(sessionID))
return ok("Unknown session ID");
StatsStorage ss = knownSessionIDs.get(sessionID);
List<Persistable> list = ss.getAllStaticInfos(sessionID, TYPE_ID);
if (list == null || list.size() == 0)
return ok();
Persistable p = list.get(0);
if (!(p instanceof FlowStaticPersistable))
return ok();
FlowStaticPersistable f = (FlowStaticPersistable) p;
return ok(Json.toJson(f.getModelInfo()));
}
代码示例来源:origin: si.urbas/pless
public static Result status() {
if (auth().isLoggedIn()) {
return ok(Json.toJson(auth().getLoggedInUserEmail()));
}
return ok(Json.toJson(false));
}
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play
private Result getModelGraph() {
boolean noData = currentSessionID == null;
StatsStorage ss = (noData ? null : knownSessionIDs.get(currentSessionID));
List<Persistable> allStatic = (noData ? Collections.EMPTY_LIST
: ss.getAllStaticInfos(currentSessionID, StatsListener.TYPE_ID));
if (allStatic.size() == 0) {
return ok();
}
TrainModuleUtils.GraphInfo gi = getGraphInfo();
if (gi == null)
return ok();
return ok(Json.toJson(gi));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
private Result getModelGraph() {
boolean noData = currentSessionID == null;
StatsStorage ss = (noData ? null : knownSessionIDs.get(currentSessionID));
List<Persistable> allStatic = (noData ? Collections.EMPTY_LIST
: ss.getAllStaticInfos(currentSessionID, StatsListener.TYPE_ID));
if (allStatic.size() == 0) {
return ok();
}
TrainModuleUtils.GraphInfo gi = getGraphInfo();
if (gi == null)
return ok();
return ok(Json.toJson(gi));
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.11
@Override
public List<Route> getRoutes() {
Route r = new Route("/weights", HttpMethod.GET, FunctionType.Supplier,
() -> ok(org.deeplearning4j.ui.views.html.histogram.Histogram.apply()));
Route r2 = new Route("/weights/listSessions", HttpMethod.GET, FunctionType.Supplier,
() -> ok(Json.toJson(knownSessionIDs.keySet())));
Route r3 = new Route("/weights/updated/:sid", HttpMethod.GET, FunctionType.Function, this::getLastUpdateTime);
Route r4 = new Route("/weights/data/:sid", HttpMethod.GET, FunctionType.Function, this::processRequest);
return Arrays.asList(r, r2, r3, r4);
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play
@Override
public List<Route> getRoutes() {
Route r = new Route("/weights", HttpMethod.GET, FunctionType.Supplier,
() -> ok(org.deeplearning4j.ui.views.html.histogram.Histogram.apply()));
Route r2 = new Route("/weights/listSessions", HttpMethod.GET, FunctionType.Supplier,
() -> ok(Json.toJson(knownSessionIDs.keySet())));
Route r3 = new Route("/weights/updated/:sid", HttpMethod.GET, FunctionType.Function, this::getLastUpdateTime);
Route r4 = new Route("/weights/data/:sid", HttpMethod.GET, FunctionType.Function, this::processRequest);
return Arrays.asList(r, r2, r3, r4);
}
代码示例来源:origin: org.deeplearning4j/deeplearning4j-play_2.10
@Override
public List<Route> getRoutes() {
Route r = new Route("/weights", HttpMethod.GET, FunctionType.Supplier,
() -> ok(org.deeplearning4j.ui.views.html.histogram.Histogram.apply()));
Route r2 = new Route("/weights/listSessions", HttpMethod.GET, FunctionType.Supplier,
() -> ok(Json.toJson(knownSessionIDs.keySet())));
Route r3 = new Route("/weights/updated/:sid", HttpMethod.GET, FunctionType.Function, this::getLastUpdateTime);
Route r4 = new Route("/weights/data/:sid", HttpMethod.GET, FunctionType.Function, this::processRequest);
return Arrays.asList(r, r2, r3, r4);
}
代码示例来源:origin: uk.gov.hmrc/microservice-bootstrap-java
public F.Promise<Result> onBadRequest(Http.RequestHeader request, String error) {
ErrorResponse er = apply(BAD_REQUEST, error, apply$default$3(), apply$default$4());
return F.Promise.pure(badRequest(toJson(er)));
}
}
代码示例来源:origin: uk.gov.hmrc/microservice-bootstrap-java
public Future<play.api.mvc.Result> onHandlerNotFound(play.api.mvc.RequestHeader request) {
ErrorResponse er = apply(NOT_FOUND, "URI not found", apply$default$3(), Some.apply(request.path()));
return Futures.successful(notFound(toJson(er)).toScala());
}
内容来源于网络,如有侵权,请联系作者删除!