本文整理汇总了Java中play.libs.Json.newObject方法的典型用法代码示例。如果您正苦于以下问题:Java Json.newObject方法的具体用法?Java Json.newObject怎么用?Java Json.newObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.libs.Json
的用法示例。
在下文中一共展示了Json.newObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDatasetColumnsByID
import play.libs.Json; //导入方法依赖的package包/类
public static Result getDatasetColumnsByID(int id)
{
List<DatasetColumn> datasetColumnList = DatasetsDAO.getDatasetColumnsByID(id);
ObjectNode result = Json.newObject();
if (datasetColumnList != null && datasetColumnList.size() > 0)
{
result.put("status", "ok");
result.set("columns", Json.toJson(datasetColumnList));
}
else
{
result.put("status", "error");
result.put("message", "record not found");
}
return ok(result);
}
示例2: watchURN
import play.libs.Json; //导入方法依赖的package包/类
public static Result watchURN()
{
Map<String, String[]> params = request().body().asFormUrlEncoded();
ObjectNode result = Json.newObject();
String username = session("user");
if (StringUtils.isNotBlank(username))
{
String message = DatasetsDAO.watchURN(params, username);
if (StringUtils.isBlank(message))
{
result.put("status", "success");
}
else
{
result.put("status", "failed");
result.put("message", message);
}
}
else
{
result.put("status", "failed");
result.put("message", "User is not authenticated");
}
return ok(result);
}
示例3: putDatasetColumnComment
import play.libs.Json; //导入方法依赖的package包/类
public static Result putDatasetColumnComment(int id, int columnId, int commentId)
{
ObjectNode result = Json.newObject();
String username = session("user");
Map<String, String[]> params = request().body().asFormUrlEncoded();
if (StringUtils.isNotBlank(username))
{
String errorMsg = DatasetsDAO.postColumnComment(id, commentId, params, username);
if (StringUtils.isBlank(errorMsg))
{
result.put("status", "success");
}
else
{
result.put("status", "failed");
result.put("msg", errorMsg);
}
}
else
{
result.put("status", "failed");
result.put("msg", "Authentication Required");
}
return ok(result);
}
示例4: getDatasetImpactAnalysisByID
import play.libs.Json; //导入方法依赖的package包/类
public static Result getDatasetImpactAnalysisByID(int id)
{
List<ImpactDataset> impactDatasetList = DatasetsDAO.getImpactAnalysisByID(id);
ObjectNode result = Json.newObject();
if (impactDatasetList != null)
{
result.put("status", "ok");
result.set("impacts", Json.toJson(impactDatasetList));
}
else
{
result.put("status", "error");
result.put("message", "record not found");
}
return ok(result);
}
示例5: addJobLineage
import play.libs.Json; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public static Result addJobLineage() {
JsonNode lineage = request().body().asJson();
ObjectNode resultJson = Json.newObject();
try {
LineageDao.insertLineage(lineage);
resultJson.put("return_code", 200);
resultJson.put("message", "Lineage inserted!");
} catch (Exception e) {
e.printStackTrace();
resultJson.put("return_code", 404);
resultJson.put("error_message", e.getMessage());
}
return ok(resultJson);
}
示例6: unfavorite
import play.libs.Json; //导入方法依赖的package包/类
public static boolean unfavorite(int id, String user)
{
ObjectNode resultNode = Json.newObject();
boolean result = false;
Integer userId = UserDAO.getUserIDByUserName(user);
if (userId != null && userId !=0)
{
int row = getJdbcTemplate().update(UNFAVORITE_A_DATASET, userId, id);
if (row > 0)
{
result = true;
}
}
return result;
}
示例7: writeEmptyJsonResponse
import play.libs.Json; //导入方法依赖的package包/类
public static void writeEmptyJsonResponse(HttpServletResponse response) {
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_OK);
try (Writer writer = response.getWriter()) {
ObjectNode data = Json.newObject();
data.set("data", new ObjectMapper().createArrayNode());
writer.write(data.toString());
} catch (IOException e) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
示例8: getAllCompanyUsers
import play.libs.Json; //导入方法依赖的package包/类
public static Result getAllCompanyUsers()
{
ObjectNode result = Json.newObject();
result.put("status", "ok");
result.set("employees", Json.toJson(UserDAO.getAllCompanyUsers()));
return ok(result);
}
示例9: postDatasetComment
import play.libs.Json; //导入方法依赖的package包/类
public static Result postDatasetComment(int id)
{
String body = request().body().asText();
ObjectNode result = Json.newObject();
String username = session("user");
Map<String, String[]> params = request().body().asFormUrlEncoded();
if (StringUtils.isNotBlank(username))
{
if (DatasetsDAO.postComment(id, params, username))
{
result.put("status", "success");
}
else
{
result.put("status", "failed");
result.put("error", "true");
result.put("msg", "Could not create comment.");
return badRequest(result);
}
}
else
{
result.put("status", "failed");
result.put("error", "true");
result.put("msg", "Unauthorized User.");
return badRequest(result);
}
return ok(result);
}
示例10: getDatasetUrns
import play.libs.Json; //导入方法依赖的package包/类
public static Result getDatasetUrns(String propertiesLike) throws SQLException {
ObjectNode resultJson = Json.newObject();
try {
if (propertiesLike != null) {
ObjectNode result = DatasetDao.getDatasetUrnForPropertiesLike(propertiesLike);
resultJson.put("return_code", 200);
resultJson.set("dataset_urns", result);
}
} catch (Exception e) {
ContrUtil.failure(resultJson, 404, e.getMessage());
Logger.error(e.getMessage());
}
return ok(resultJson);
}
示例11: unwatchDataset
import play.libs.Json; //导入方法依赖的package包/类
public static Result unwatchDataset(int id, int watchId)
{
ObjectNode result = Json.newObject();
if (DatasetsDAO.unwatch(watchId))
{
result.put("status", "success");
}
else
{
result.put("status", "failed");
}
return ok(result);
}
示例12: getSchemaHistory
import play.libs.Json; //导入方法依赖的package包/类
public static Result getSchemaHistory(int id)
{
ObjectNode result = Json.newObject();
result.put("status", "ok");
result.set("data", Json.toJson(SchemaHistoryDAO.getSchemaHistoryByDatasetID(id)));
return ok(result);
}
示例13: updateDb
import play.libs.Json; //导入方法依赖的package包/类
public static Result updateDb() {
JsonNode db = request().body().asJson();
ObjectNode resultJson = Json.newObject();
try {
CfgDao.updateDb(db);
resultJson.put("return_code", 200);
resultJson.put("message", "App updated!");
} catch (Exception e) {
e.printStackTrace();
resultJson.put("return_code", 404);
resultJson.put("error_message", e.getMessage());
}
return ok(resultJson);
}
示例14: ownDataset
import play.libs.Json; //导入方法依赖的package包/类
public static Result ownDataset(int id)
{
ObjectNode result = Json.newObject();
String username = session("user");
if (StringUtils.isNotBlank(username))
{
result = DatasetsDAO.ownDataset(id, username);
}
else
{
result.put("status", "failed");
}
return ok(result);
}
示例15: getFlowSchedules
import play.libs.Json; //导入方法依赖的package包/类
public static Result getFlowSchedules(String flowPath) {
String instance = request().getQueryString("instance");
ObjectNode resultJson = Json.newObject();
try {
List<Map<String, Object>> schedules = FlowDao.getFlowSchedules(flowPath, instance);
resultJson.put("return_code", 200);
resultJson.set("schedules", Json.toJson(schedules));
} catch (Exception e) {
e.printStackTrace();
resultJson.put("return_code", 404);
resultJson.put("error_message", e.getMessage());
}
return ok(resultJson);
}