当前位置: 首页>>代码示例>>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;未经允许,请勿转载。