當前位置: 首頁>>代碼示例>>Java>>正文


Java Json.newObject方法代碼示例

本文整理匯總了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);
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:20,代碼來源:Dataset.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:27,代碼來源:Dataset.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:27,代碼來源:Dataset.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:20,代碼來源:Dataset.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:17,代碼來源:LineageController.java

示例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;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:17,代碼來源:DatasetsDAO.java

示例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);
    }
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:12,代碼來源:RemoteServerHelper.java

示例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);
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:9,代碼來源:User.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:32,代碼來源:Dataset.java

示例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);
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:16,代碼來源:DatasetController.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:15,代碼來源:Dataset.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:9,代碼來源:SchemaHistory.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:16,代碼來源:CfgController.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:16,代碼來源:Dataset.java

示例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);
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:16,代碼來源:FlowController.java


注:本文中的play.libs.Json.newObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。