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


Java ObjectNode.get方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.node.ObjectNode.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode.get方法的具體用法?Java ObjectNode.get怎麽用?Java ObjectNode.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.node.ObjectNode的用法示例。


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

示例1: addFulfillments

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private static void addFulfillments(final ObjectNode transactionEnvelopeNode, final List<KeyPair> keyPairs) {
    final String canonicalString = JsonCanonicalizer.json2CanonicalString(transactionEnvelopeNode);
    Ed25519Fulfillment fulfillment =
            Ed25519Fulfillment.BuildFromSecrets(keyPairs.get(0), new MessagePayload(encodeUtf8(canonicalString)));
    final ObjectNode fulfillmentNode = jsonNodeFactory.objectNode();
    fulfillmentNode.set("fulfillment", jsonNodeFactory.textNode(fulfillment.toURI()));
    fulfillmentNode.set("fulfills", jsonNodeFactory.nullNode());
    final ArrayNode ownersBefore = jsonNodeFactory.arrayNode();
    ownersBefore.add(jsonNodeFactory.textNode(Base58.base58Encode(keyPairs.get(0).getPublic().getEncoded())));
    fulfillmentNode.set("owners_before", ownersBefore);

    JsonNode fulfillments = transactionEnvelopeNode.get("inputs");
    if (fulfillments == null || !fulfillments.isArray()) {
        throw new RuntimeException("Badly structured transaction does not contain \"inputs\": " + transactionEnvelopeNode);
    }
    ((ArrayNode) fulfillments).set(0, fulfillmentNode);
}
 
開發者ID:mgrand,項目名稱:bigchaindb-java-driver,代碼行數:18,代碼來源:SignedBigchaindbTransactionFactory.java

示例2: updatePortPain

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Update details of a specified port chain id.
 *
 * @param id port chain id
 * @param stream port chain json
 * @return 200 OK, 404 if given identifier does not exist
 */
@PUT
@Path("{chain_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response updatePortPain(@PathParam("chain_id") String id,
                               final InputStream stream) {
    try {
        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        JsonNode port = jsonTree.get("port_chain");
        PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this);
        Boolean result = nullIsNotFound(get(PortChainService.class).updatePortChain(portChain),
                                        PORT_CHAIN_NOT_FOUND);
        return Response.status(OK).entity(result.toString()).build();
    } catch (IOException e) {
        log.error("Update port chain failed because of exception {}.", e.toString());
        throw new IllegalArgumentException(e);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:PortChainWebResource.java

示例3: createFlows

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Creates new flow rules. Creates and installs a new flow rules.<br>
 * Instructions description:
 * https://wiki.onosproject.org/display/ONOS/Flow+Rule+Instructions
 * <br>
 * Criteria description:
 * https://wiki.onosproject.org/display/ONOS/Flow+Rule+Criteria
 *
 * @param stream flow rules JSON
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel FlowsBatchPost
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createFlows(@QueryParam("appId") String appId, InputStream stream) {
    try {
        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        ArrayNode flowsArray = (ArrayNode) jsonTree.get(FLOWS);

        if (appId != null) {
            flowsArray.forEach(flowJson -> ((ObjectNode) flowJson).put("appId", appId));
        }

        List<FlowRule> rules = codec(FlowRule.class).decode(flowsArray, this);
        service.applyFlowRules(rules.toArray(new FlowRule[rules.size()]));
        rules.forEach(flowRule -> {
            ObjectNode flowNode = mapper().createObjectNode();
            flowNode.put(DEVICE_ID, flowRule.deviceId().toString())
                    .put(FLOW_ID, flowRule.id().value());
            flowsNode.add(flowNode);
        });
    } catch (IOException ex) {
        throw new IllegalArgumentException(ex);
    }
    return Response.ok(root).build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:39,代碼來源:FlowsWebResource.java

示例4: modifyReleasedVersions

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private void modifyReleasedVersions(JsonNode tree, boolean recurse) {
    for (String dependencyKey : NpmDependencyKinds.DEPENDENCY_KEYS) {
        JsonNode dependencies = tree.get(dependencyKey);
        if (dependencies instanceof ObjectNode) {
            ObjectNode objectNode = (ObjectNode) dependencies;
            modifyReleasedVersionsChild(objectNode);


            // we are in a child dependency of a released version so lets check for
            // any transitive versions to update too
            if (recurse) {
                Iterator<String> iter = objectNode.fieldNames();
                while (iter.hasNext()) {
                    String field = iter.next();
                    JsonNode dependentPackage = objectNode.get(field);
                    if (dependentPackage != null) {
                        modifyReleasedVersions(dependentPackage, true);
                    }
                }
            }
        }
    }
}
 
開發者ID:fabric8-updatebot,項目名稱:updatebot,代碼行數:24,代碼來源:TestNpmDependencyTreeGenerator.java

示例5: doGet

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
	String postfixKey = "";
	String forwardUrl = null;

	String state = req.getParameter(STATE_CALLBACK_PARAMETER);
	if( state != null )
	{
		ObjectNode stateJson = (ObjectNode) new ObjectMapper().readTree(brightspaceConnectorService.decrypt(state));
		JsonNode forwardUrlNode = stateJson.get(BrightspaceConnectorConstants.STATE_KEY_FORWARD_URL);
		if( forwardUrlNode != null )
		{
			forwardUrl = forwardUrlNode.asText();
		}

		JsonNode postfixKeyNode = stateJson.get(BrightspaceConnectorConstants.STATE_KEY_POSTFIX_KEY);
		if( postfixKeyNode != null )
		{
			postfixKey = postfixKeyNode.asText();
		}
	}

	sessionService.setAttribute(BrightspaceConnectorConstants.SESSION_KEY_USER_ID + postfixKey,
		req.getParameter(USER_ID_CALLBACK_PARAMETER));
	sessionService.setAttribute(BrightspaceConnectorConstants.SESSION_KEY_USER_KEY + postfixKey,
		req.getParameter(USER_KEY_CALLBACK_PARAMETER));

	//close dialog OR redirect...
	if( forwardUrl != null )
	{
		resp.sendRedirect(forwardUrl);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:35,代碼來源:BrightspaceOauthSignonServlet.java

示例6: modifyReleasedVersionsChild

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private void modifyReleasedVersionsChild(ObjectNode dependencyNode) {
    for (Map.Entry<String, String> entry : simuatedReleases.entrySet()) {
        String dependency = entry.getKey();
        String version = entry.getValue();

        JsonNode node = dependencyNode.get(dependency);
        if (node instanceof ObjectNode) {
            ObjectNode objectNode = (ObjectNode) node;
            objectNode.put("version", version);

            // recurse through children if we find anything
            modifyReleasedVersions(objectNode, true);
        }
    }
}
 
開發者ID:fabric8-updatebot,項目名稱:updatebot,代碼行數:16,代碼來源:TestNpmDependencyTreeGenerator.java

示例7: merge

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private JsonNode merge(JsonNode container, JsonNode value, String key) {
	ObjectNode into = container.isMissingNode() ? JsonOverlay.jsonObject() : (ObjectNode) container;
	ObjectNode result = into;
	if (key != null) {
		into = into.has(key) ? (ObjectNode) into.get(key) : into.putObject(key);
	}
	if (!value.isMissingNode()) {
		ObjectNode from = (ObjectNode) value;
		for (Entry<String, JsonNode> field : JsonOverlay.iterable(from.fields())) {
			into.set(field.getKey(), field.getValue());
		}
	}
	return result;
}
 
開發者ID:networknt,項目名稱:openapi-parser,代碼行數:15,代碼來源:JsonPath.java

示例8: getFromJsonStream

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Get the tenant identifier from the JSON stream.
 *
 * @param stream        TenantId JSON stream
 * @param jsonFieldName field name
 * @return JsonNode
 * @throws IOException if unable to parse the request
 */
private JsonNode getFromJsonStream(InputStream stream, String jsonFieldName) throws IOException {
    ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
    JsonNode jsonNode = jsonTree.get(jsonFieldName);

    if (jsonNode == null) {
        throw new IllegalArgumentException(MISSING_FIELD + jsonFieldName);
    }
    return jsonNode;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:VirtualNetworkWebResource.java

示例9: recurseFolders

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private void recurseFolders(ObjectNode structureJson, TargetFolder folder, SelectionSession session)
{
	folder.setName(nodeValue(structureJson, "name", resources.getString("selection.folder.untitled")));
	final boolean targetable = nodeValue(structureJson, "targetable", true);
	folder.setTargetable(targetable);

	final String id = nodeValue(structureJson, "id", null);
	if( id == null && targetable )
	{
		throw new RuntimeException("Each targetable folder must have an 'id' field.");
	}
	folder.setId(id);

	final boolean defaultFolder = nodeValue(structureJson, "selected", false);
	folder.setDefaultFolder(defaultFolder);
	if( defaultFolder )
	{
		session.setTargetFolder(id);
	}

	final JsonNode folders = structureJson.get("folders");
	if( folders != null )
	{
		if( !folders.isArray() )
		{
			throw new RuntimeException("'folders' field must be an array.");
		}
		final ArrayNode foldersArray = (ArrayNode) folders;
		for( JsonNode folderJson : foldersArray )
		{
			if( folderJson.isObject() )
			{
				final TargetFolder subfolder = new TargetFolder();
				folder.addFolder(subfolder);
				recurseFolders((ObjectNode) folderJson, subfolder, session);
			}
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:40,代碼來源:StructuredIntegrationSessionExtension.java

示例10: decodeExtension

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Override
public ExtFlowTypes decodeExtension(ObjectNode json) {
    if (json == null || !json.isObject()) {
        return null;
    }

    ExtTarget.Builder resultBuilder = new DefaultExtTarget.Builder();

    JsonNode jsonNodes = json.get(BgpFlowExtensionCodec.WIDE_COMM_EXT_TARGET);
    if (jsonNodes == null) {
        nullIsIllegal(json.get(BgpFlowExtensionCodec.WIDE_COMM_EXT_TARGET),
                BgpFlowExtensionCodec.WIDE_COMM_EXT_TARGET + MISSING_MEMBER_MESSAGE).asText();
    }

    JsonNode array = jsonNodes.path(BgpFlowExtensionCodec.WIDE_COMM_TGT_LOCAL_SP);
    if (array == null) {
        nullIsIllegal(array, BgpFlowExtensionCodec.WIDE_COMM_TGT_LOCAL_SP + MISSING_MEMBER_MESSAGE).asText();
    }

    ExtPrefix.Builder resultBuilderPfx = parseIpArrayToPrefix(array);
    resultBuilderPfx.setType(ExtFlowTypes.ExtType.IPV4_SRC_PFX);
    resultBuilder.setLocalSpeaker(resultBuilderPfx.build());

    array = jsonNodes.path(BgpFlowExtensionCodec.WIDE_COMM_TGT_REMOTE_SP);
    if (array == null) {
        nullIsIllegal(array, BgpFlowExtensionCodec.WIDE_COMM_TGT_REMOTE_SP + MISSING_MEMBER_MESSAGE).asText();
    }

    resultBuilderPfx = parseIpArrayToPrefix(array);
    resultBuilderPfx.setType(ExtFlowTypes.ExtType.IPV4_DST_PFX);
    resultBuilder.setRemoteSpeaker(resultBuilderPfx.build());
    resultBuilder.setType(ExtFlowTypes.ExtType.WIDE_COMM_EXT_TARGET);

    return resultBuilder.build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:36,代碼來源:DecodeBgpFlowExtnCodecHelper.java

示例11: setMapping

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Post a new static MAC/IP binding.
 * Registers a static binding to the DHCP server, and displays the current set of bindings.
 *
 * @onos.rsModel DhcpConfigPut
 * @param stream JSON stream
 * @return 200 OK
 */
@POST
@Path("mappings")
@Consumes(MediaType.APPLICATION_JSON)
public Response setMapping(InputStream stream) {
    ObjectNode root = mapper().createObjectNode();
    try {
        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        JsonNode macID = jsonTree.get("mac");
        JsonNode ip = jsonTree.get("ip");
        if (macID != null && ip != null) {
            IpAssignment ipAssignment = IpAssignment.builder()
                    .ipAddress(Ip4Address.valueOf(ip.asText()))
                    .leasePeriod(service.getLeaseTime())
                    .timestamp(new Date())
                    .assignmentStatus(Option_Requested)
                    .build();

            if (!service.setStaticMapping(MacAddress.valueOf(macID.asText()),
                                          ipAssignment)) {
                throw new IllegalArgumentException("Static Mapping Failed. " +
                                                           "The IP maybe unavailable.");
            }
        }

        final Map<HostId, IpAssignment> intents = service.listMapping();
        ArrayNode arrayNode = root.putArray("mappings");
        intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
                                                              .put("host", i.getKey().toString())
                                                              .put("ip", i.getValue().ipAddress().toString())));
    } catch (IOException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
    return ok(root).build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:43,代碼來源:DhcpWebResource.java

示例12: checkFields

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private boolean checkFields(ObjectNode node, Set<String> original) {
    Iterator<String> fieldNames = node.fieldNames();
    while (fieldNames.hasNext()) {
        String fieldName = fieldNames.next();
        if (!original.contains(fieldName) || node.get(fieldName) == null) {
            log.warn("Illegal field name: {}", fieldName);
            return false;
        }
    }
    return true;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:12,代碼來源:SystemMetricsCollectorWebResource.java

示例13: multiEncryptionSerializationTest

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Test
public void multiEncryptionSerializationTest() {
    Set<KeyPair> keyPairs = generateKeyPairs(3);
    final MultiEncryption multiEncryption
            = new MultiEncryption(key24, keyPairs.stream().map(KeyPair::getPublic).collect(Collectors.toList()));
    final ObjectNode jsonObject = (ObjectNode) JsonUtil.multiEncryptionToJson(multiEncryption);
    jsonObject.get(JsonUtil.ENCRYPTION_ALGORITHM_NAME).asText();
    assertEquals(JsonUtil.VERSION1_0, jsonObject.get(JsonUtil.VERSION_NAME).asText());
    assertEquals("RSA", jsonObject.get(JsonUtil.ENCRYPTION_ALGORITHM_NAME).asText());
    final ObjectNode keysObject = (ObjectNode) jsonObject.get(JsonUtil.ENCRYPTIONS_NAME);
    assertEquals(3, keysObject.size());
}
 
開發者ID:mgrand,項目名稱:crypto-shuffle,代碼行數:13,代碼來源:JsonUtilTest.java

示例14: decode

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
public Objective.Builder decode(ObjectNode json, Objective.Builder builder, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    // permanent
    boolean permanent = false;
    if (json.get(PERMANENT) != null) {
        permanent = json.get(PERMANENT).asBoolean();
    }

    // timeout
    int timeoutInt = 0;
    if (json.get(TIMEOUT) != null) {
        timeoutInt = json.get(TIMEOUT).asInt();
    }

    // priority
    int priorityInt = 0;
    if (json.get(PRIORITY) != null) {
        priorityInt = json.get(PRIORITY).asInt();
    }

    if (permanent) {
        builder.makePermanent()
                .withPriority(priorityInt);
    } else {
        builder.makeTemporary(timeoutInt)
                .withPriority(priorityInt);
    }
    return builder;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:33,代碼來源:ObjectiveCodecHelper.java

示例15: decode

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Override
public OpenstackNetwork decode(ObjectNode json, CodecContext context) {

    JsonNode networkInfo = json.get(NETWORK);
    if (networkInfo == null) {
        networkInfo = json;
    }

    String name = networkInfo.path(NAME).asText();
    String tenantId = networkInfo.path(TENANT_ID).asText();
    String id = networkInfo.path(ID).asText();

    OpenstackNetwork.Builder onb = OpenstackNetwork.builder();
    onb.name(name)
            .tenantId(tenantId)
            .id(id);

    if (networkInfo.path(NETWORK_TYPE).isMissingNode()) {
        log.debug("Network {} has no network type, ignore it.", name);
        return null;
    }

    String networkType = networkInfo.path(NETWORK_TYPE).asText();
    try {
        onb.networkType(OpenstackNetwork.NetworkType.valueOf(networkType.toUpperCase()));
    } catch (IllegalArgumentException e) {
        log.debug("Network {} has unsupported network type {}, ignore it.",
                 name, networkType);
        return null;
    }

    onb.segmentId(networkInfo.path(SEGMENTATION_ID).asText());

    return onb.build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:36,代碼來源:OpenstackNetworkCodec.java


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