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


Java ObjectNode類代碼示例

本文整理匯總了Java中org.codehaus.jackson.node.ObjectNode的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode類的具體用法?Java ObjectNode怎麽用?Java ObjectNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectNode類屬於org.codehaus.jackson.node包,在下文中一共展示了ObjectNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deserialize

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@Override
public Directive deserialize(JsonParser jp, DeserializationContext ctx)
        throws IOException {
    ObjectReader reader = ObjectMapperUtil.instance().getObjectReader();
    ObjectNode obj = (ObjectNode) reader.readTree(jp);
    Iterator<Map.Entry<String, JsonNode>> elementsIterator = obj.getFields();

    String rawMessage = obj.toString();
    DialogRequestIdHeader header = null;
    JsonNode payloadNode = null;
    ObjectReader headerReader =
            ObjectMapperUtil.instance().getObjectReader(DialogRequestIdHeader.class);
    while (elementsIterator.hasNext()) {
        Map.Entry<String, JsonNode> element = elementsIterator.next();
        if (element.getKey().equals("header")) {
            header = headerReader.readValue(element.getValue());
        }
        if (element.getKey().equals("payload")) {
            payloadNode = element.getValue();
        }
    }
    if (header == null) {
        throw ctx.mappingException("Missing header");
    }
    if (payloadNode == null) {
        throw ctx.mappingException("Missing payload");
    }

    return createDirective(header, payloadNode, rawMessage);
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:31,代碼來源:Directive.java

示例2: createAuthLinkResponse

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
public static String createAuthLinkResponse(){

        JsonNodeFactory f = JsonNodeFactory.instance ;
        ObjectNode loginResponse = f.objectNode();
        loginResponse.put("text","Authorization for SkyGiraffe to use Slack details is required.");
        ArrayNode attachments = loginResponse.putArray("attachments");
        ObjectNode att = f.objectNode();
        att.put("fallback", "Please authorize SkyGiraffe to access to your Slack details ...");
        att.put("pretext", "");
        att.put("title", "Please authorize..");
        att.put("title_link", Config.getPropertyValue("SLACK_AUTH_URL_DEV"));
        att.put("text","Once authorized and logged into SkyGiraffe try '/sg help' to see all commands");
        att.put("color", "#7CD197");

        attachments.add(att);
        return loginResponse.toString();

    }
 
開發者ID:skygiraffe,項目名稱:skygiraffe-slackbot,代碼行數:19,代碼來源:JsonUtil.java

示例3: getClusterAsJson

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@Path("list")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String   getClusterAsJson() throws Exception
{
    InstanceConfig      config = context.getExhibitor().getConfigManager().getConfig();

    ObjectNode          node = JsonNodeFactory.instance.objectNode();

    ArrayNode           serversNode = JsonNodeFactory.instance.arrayNode();
    ServerList          serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC));
    for ( ServerSpec spec : serverList.getSpecs() )
    {
        serversNode.add(spec.getHostname());
    }
    node.put("servers", serversNode);
    node.put("port", config.getInt(IntConfigs.CLIENT_PORT));

    return JsonUtil.writeValueAsString(node);
}
 
開發者ID:dcos,項目名稱:exhibitor,代碼行數:21,代碼來源:ClusterResource.java

示例4: getCriteria

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
public static Criteria getCriteria(ObjectNode rudeCriteria) throws Exception {
	Criteria criteria = new Criteria();
	if (rudeCriteria.has("criterions")) {
		ArrayNode criterions = (ArrayNode) rudeCriteria.get("criterions");
		if (criterions != null) {
			for (Iterator<JsonNode> it = criterions.iterator(); it.hasNext();) {
				criteria.addCriterion(parseCriterion((ObjectNode) it.next()));
			}
		}
	}

	if (rudeCriteria.has("orders")) {
		ArrayNode orders = (ArrayNode) rudeCriteria.get("orders");
		if (orders != null) {
			for (Iterator<JsonNode> it = orders.iterator(); it.hasNext();) {
				ObjectNode rudeCriterion = (ObjectNode) it.next();
				Order order = new Order(JsonUtils.getString(rudeCriterion, "property"), JsonUtils.getBoolean(rudeCriterion, "desc"));
				criteria.addOrder(order);
			}
		}
	}
	return criteria;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:24,代碼來源:CriterionUtils.java

示例5: extractCrosspostBlogs

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
/**
 * Extracts the crosspost blogs from an autosave and creates a JSON array.
 *
 * @param item
 *            the item that holds the note data
 * @return the array
 */
private ArrayNode extractCrosspostBlogs(AutosaveNoteData item) {
    ArrayNode result = JsonHelper.getSharedObjectMapper().createArrayNode();
    if (item.getCrosspostBlogs() != null) {
        for (BlogData b : item.getCrosspostBlogs()) {
            String title = b.getTitle();
            ObjectNode blog = BlogSearchHelper.createBlogSearchJSONResult(b.getId(),
                    b.getNameIdentifier(), title, false);
            result.add(blog);
        }
    }
    if (result.size() == 0) {
        return null;
    }
    return result;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:23,代碼來源:CreateNoteWidget.java

示例6: extractUserData

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void extractUserData(ObjectNode jsonUser, ExternalUserVO userVO)
        throws AuthenticationServiceException {
    assertFieldsExist(jsonUser, JSON_PARAM_LOGIN, JSON_PARAM_EMAIL, JSON_PARAM_LAST_NAME,
            JSON_PARAM_FIRST_NAME);
    userVO.setExternalUserName(jsonUser.get(JSON_PARAM_LOGIN).asText());
    userVO.setEmail(jsonUser.get(JSON_PARAM_EMAIL).asText());
    userVO.setLastName(jsonUser.get(JSON_PARAM_LAST_NAME).asText());
    userVO.setFirstName(jsonUser.get(JSON_PARAM_FIRST_NAME).asText());
    if (jsonUser.has(JSON_PARAM_LANG)) {
        String lang = jsonUser.get(JSON_PARAM_LANG).asText();
        Locale locale = new Locale(lang);
        userVO.setDefaultLanguage(locale);
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:19,代碼來源:ConfluenceAuthenticator.java

示例7: createLoginLinkResponse

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
/**
 * {
 "attachments": [
 {
 "fallback": "Please login into SkyGiraffe to continue ...",
 "pretext": "SkyGiraffe Login",
 "title": "Please login into SkyGiraffe to continue ...",
 "title_link": "https://sgbot-mobilityai.rhcloud.com/SGbot-1.0/skyg/login?key=",
 "text": "Once logged in try '/sg help' to see all commands",
 "color": "#7CD197"
 }
 ]
 }
 * @return
 */
public static String createLoginLinkResponse(String slackUserId, String email, String teamId){

    JsonNodeFactory f = JsonNodeFactory.instance ;
    ObjectNode loginResponse = f.objectNode();
    loginResponse.put("text","Login to SkyGiraffe is required.");
    ArrayNode attachments = loginResponse.putArray("attachments");
    ObjectNode att = f.objectNode();
    att.put("fallback", "Please login into SkyGiraffe to continue ...");
    att.put("pretext", "");
    att.put("title", "Please login..");
    att.put("title_link", Config.getPropertyValue("SGDS_LOGIN_URL_DEV")+slackUserId+"&EMAIL="+email+"&TEAMID="+teamId);
    att.put("text","Once logged in try '/sg help' to see all commands");
    att.put("color", "#7CD197");

    attachments.add(att);

    return loginResponse.toString();

}
 
開發者ID:skygiraffe,項目名稱:skygiraffe-slackbot,代碼行數:35,代碼來源:JsonUtil.java

示例8: authenticate

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
public static String authenticate(String userName, String password) throws IOException {
    if (userName == null || userName.isEmpty())
        userName = SGSlackConstants.DEFAULT_USER;
    if (password == null || password.isEmpty())
        password = SGSlackConstants.PASSWORD;

    ObjectMapper m = new ObjectMapper();
    ObjectNode o = m.createObjectNode();
    o.put("UserName",userName);
    o.put("Password",password);
    o.put("OS","webapp");
    o.put("Version","4006000");

    StringEntity input = new StringEntity(o.toString());

    SGDSAuthRes ss = new SGDSAuthRes();
    ss = m.readValue(postSGDS("Authenticate",input), ss.getClass());

    logger.debug("Session id on authentication="+ss.getSessionID());
    return ss.getSessionID();
}
 
開發者ID:skygiraffe,項目名稱:skygiraffe-slackbot,代碼行數:22,代碼來源:SGDSClient.java

示例9: userValidation

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@PUT
@Path("/validate")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response userValidation(User userData) {
	try {
		int flag = 0;
		String emailRcvd = "";

		final ObjectNode node = new ObjectMapper().readValue(userData.toString(), ObjectNode.class);

		if (node.has("email")) {
			emailRcvd = node.get("email").toString().replace("\"", "").trim();
		}

		ResultSet rs = dbobj.openConnection("select email from user");
		while (rs.next()) {
			String userEmail = rs.getString("email");
			if (emailRcvd.equals(userEmail)) {
				flag = 1;
				break;
			}
		}
		if (flag == 1) {
			resp.put("response", "false");
			return Response.ok(resp.toJSONString()).build();
		}
		dbobj.closeConnection(rs);
	} catch (SQLException | IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	resp.put("response", "true");
	return Response.ok(resp.toJSONString()).build();
}
 
開發者ID:akhildabral,項目名稱:SHIKSHAK,代碼行數:37,代碼來源:SignupService.java

示例10: countersToJSON

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@Private
public JsonNode countersToJSON(Counters counters) {
  ObjectMapper mapper = new ObjectMapper();
  ArrayNode nodes = mapper.createArrayNode();
  if (counters != null) {
    for (CounterGroup counterGroup : counters) {
      ObjectNode groupNode = nodes.addObject();
      groupNode.put("NAME", counterGroup.getName());
      groupNode.put("DISPLAY_NAME", counterGroup.getDisplayName());
      ArrayNode countersNode = groupNode.putArray("COUNTERS");
      for (Counter counter : counterGroup) {
        ObjectNode counterNode = countersNode.addObject();
        counterNode.put("NAME", counter.getName());
        counterNode.put("DISPLAY_NAME", counter.getDisplayName());
        counterNode.put("VALUE", counter.getValue());
      }
    }
  }
  return nodes;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:JobHistoryEventHandler.java

示例11: deserialize

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@Override
public StatePair deserialize(JsonParser parser, 
                             DeserializationContext context)
throws IOException, JsonProcessingException {
  ObjectMapper mapper = (ObjectMapper) parser.getCodec();
  // set the state-pair object tree
  ObjectNode statePairObject = (ObjectNode) mapper.readTree(parser);
  Class<?> stateClass = null;
  
  try {
    stateClass = 
      Class.forName(statePairObject.get("className").getTextValue().trim());
  } catch (ClassNotFoundException cnfe) {
    throw new RuntimeException("Invalid classname!", cnfe);
  }
  
  String stateJsonString = statePairObject.get("state").toString();
  State state = (State) mapper.readValue(stateJsonString, stateClass);
  
  return new StatePair(state);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:StateDeserializer.java

示例12: doGet

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    PrintWriter out = resp.getWriter();
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode root = mapper.getNodeFactory().objectNode();

    HttpSession session = req.getSession(false);
    int orderId = (int)session.getAttribute("currentOrder");
    int userId = -1;
    if(orderId != -1){
        boolean success = (boolean)session.getAttribute("success");
        if(success){
            userId = (int)session.getAttribute("id_user");
        }
        OrderDBManager orderDBManager = new OrderDBManager();
        root.put("orderProperties",orderCollection(orderDBManager.get(orderId)));

    }
    root.put("currentUser",userId);
    root.put("order",orderId);
    out.append(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
    out.flush();
}
 
開發者ID:SergeyZhernovoy,項目名稱:Java-education,代碼行數:25,代碼來源:UpdateOrder.java

示例13: orderCollection

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
public ArrayNode orderCollection(Collection<Order> collection) {
    ArrayNode array = JsonNodeFactory.instance.arrayNode();
    for(Order param : collection){
        ObjectNode obj =  JsonNodeFactory.instance.objectNode();
        obj.put("orderId", param.getId() );
        obj.put("mile", param.getMilesage() );
        obj.put("price", param.getPrice() );
        obj.put("sold", param.getSold() );
        obj.put("carName", param.getCar().getName() );
        obj.put("carId", param.getCar().getId() );
        obj.put("modelId", param.getCar().getModel().getId() );
        obj.put("bodyId", param.getCar().getBody().getId() );
        obj.put("drivetype", param.getCar().getDriveType().getId());
        obj.put("engineId", param.getCar().getEngine().getId() );
        obj.put("transsmId", param.getCar().getTransmission().getId() );
        obj.put("data", param.getRelease().getTime());
        obj.put("userId", param.getUser().getId() );
        array.add(obj);
    }
    return array;
}
 
開發者ID:SergeyZhernovoy,項目名稱:Java-education,代碼行數:22,代碼來源:UpdateOrder.java

示例14: getBackupConfig

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
@Path("backup-config")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getBackupConfig() throws Exception
{
    ArrayNode           node = JsonNodeFactory.instance.arrayNode();

    if ( context.getExhibitor().getBackupManager().isActive() )
    {
        EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser();
        List<BackupConfigSpec>  configs = context.getExhibitor().getBackupManager().getConfigSpecs();
        for ( BackupConfigSpec c : configs )
        {
            ObjectNode      n = JsonNodeFactory.instance.objectNode();
            String          value = parser.getValue(c.getKey());

            n.put("key", c.getKey());
            n.put("name", c.getDisplayName());
            n.put("help", c.getHelpText());
            n.put("value", (value != null) ? value : "");
            n.put("type", c.getType().name().toLowerCase().substring(0, 1));

            node.add(n);
        }
    }

    return JsonUtil.writeValueAsString(node);
}
 
開發者ID:dcos,項目名稱:exhibitor,代碼行數:29,代碼來源:UIResource.java

示例15: getAppList

import org.codehaus.jackson.node.ObjectNode; //導入依賴的package包/類
public static String getAppList(String sessionId) throws IOException {

        if (sessionId == null || sessionId.isEmpty())
            throw new IllegalArgumentException("Session Id is empty. Please login.");

        ObjectMapper m = new ObjectMapper();
        ObjectNode o = m.createObjectNode();
        o.put("SessionID",sessionId);
        StringEntity inputApps = new StringEntity(o.toString());
        return postSGDS("GetAppsList", inputApps);
    }
 
開發者ID:skygiraffe,項目名稱:skygiraffe-slackbot,代碼行數:12,代碼來源:SGDSClient.java


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