• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Jackson类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.util.json.Jackson的典型用法代码示例。如果您正苦于以下问题:Java Jackson类的具体用法?Java Jackson怎么用?Java Jackson使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Jackson类属于com.amazonaws.util.json包,在下文中一共展示了Jackson类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handle

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
@Override
public void handle(Context ctx) throws Exception {
    String token = null;
    List<Voice> voices = new ArrayList<>();

    while (true) {
        DescribeVoicesResult result;
        if (token == null) {
            result = polly.describeVoices(new DescribeVoicesRequest());
        } else {
            result = polly.describeVoices(new DescribeVoicesRequest().withNextToken(token));
        }

        voices.addAll(result.getVoices());

        if (result.getNextToken() != null) {
            token = result.getNextToken();
        } else {
            ctx.render(Jackson.toJsonString(voices));
            break;
        }
    }
}
 
开发者ID:gregwhitaker,项目名称:aws-polly-example,代码行数:24,代码来源:PollyVoicesHandler.java


示例2: handleErrorResponse

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
private void handleErrorResponse(InputStream errorStream, int statusCode, String responseMessage) throws IOException {
    String errorCode = null;

    // Parse the error stream returned from the service.
    if(errorStream != null) {
        String errorResponse = IOUtils.toString(errorStream);

        try {
            JsonNode node = Jackson.jsonNodeOf(errorResponse);
            JsonNode code = node.get("code");
            JsonNode message = node.get("message");
            if (code != null && message != null) {
                errorCode = code.asText();
                responseMessage = message.asText();
            }
        } catch (Exception exception) {
            LOG.debug("Unable to parse error stream");
        }
    }

    AmazonServiceException ase = new AmazonServiceException(responseMessage);
    ase.setStatusCode(statusCode);
    ase.setErrorCode(errorCode);
    throw ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:EC2CredentialsUtils.java


示例3: toJsonString

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
/**
 * Returns the json string in the latest format.
 */
private String toJsonString() {
    Map<String, String> map = new HashMap<String, String>();
    byte[] encryptedCEK = getEncryptedCEK();
    map.put(Headers.CRYPTO_KEY_V2, Base64.encodeAsString(encryptedCEK));
    byte[] iv = cipherLite.getIV();
    map.put(Headers.CRYPTO_IV, Base64.encodeAsString(iv));
    map.put(Headers.MATERIALS_DESCRIPTION, kekMaterialDescAsJson());
    // The CRYPTO_CEK_ALGORITHM, CRYPTO_TAG_LENGTH and
    // CRYPTO_KEYWRAP_ALGORITHM were not available in the Encryption Only
    // (EO) implementation
    ContentCryptoScheme scheme = getContentCryptoScheme();
    map.put(Headers.CRYPTO_CEK_ALGORITHM, scheme.getCipherAlgorithm());
    int tagLen = scheme.getTagLengthInBits();
    if (tagLen > 0)
        map.put(Headers.CRYPTO_TAG_LENGTH, String.valueOf(tagLen));
    String keyWrapAlgo = getKeyWrappingAlgorithm();
    if (keyWrapAlgo != null)
        map.put(Headers.CRYPTO_KEYWRAP_ALGORITHM, keyWrapAlgo);
    return Jackson.toJsonString(map);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:ContentCryptoMaterial.java


示例4: TripEvent

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
public TripEvent(String payload)  {
  super(payload);

  JsonNode json = Jackson.fromJsonString(payload, JsonNode.class);
  this.tripId = json.get("trip_id").asLong();
  this.timestamp = new DateTime(json.get("dropoff_datetime").asText()).getMillis();
}
 
开发者ID:awslabs,项目名称:flink-stream-processing-refarch,代码行数:8,代码来源:TripEvent.java


示例5: createPolicyFromJsonString

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
/**
 * Converts the specified JSON string to an AWS policy object.
 *
 * For more information see, @see
 * http://docs.aws.amazon.com/AWSSdkDocsJava/latest
 * /DeveloperGuide/java-dg-access-control.html
 *
 * @param jsonString
 *            the specified JSON string representation of this AWS access
 *            control policy.
 *
 * @return An AWS policy object.
 *
 * @throws IllegalArgumentException
 *             If the specified JSON string is null or invalid and cannot be
 *             converted to an AWS policy object.
 */
public Policy createPolicyFromJsonString(String jsonString) {
    if (jsonString == null) {
        throw new IllegalArgumentException("JSON string cannot be null");
    }

    JsonNode policyNode;
    JsonNode idNode;
    JsonNode statementNodes;
    Policy policy = new Policy();
    List<Statement> statements = new LinkedList<Statement>();

    try {
        policyNode = Jackson.jsonNodeOf(jsonString);

        idNode = policyNode.get(JsonDocumentFields.POLICY_ID);
        if (isNotNull(idNode)) {
            policy.setId(idNode.asText());
        }

        statementNodes = policyNode.get(JsonDocumentFields.STATEMENT);
        if (isNotNull(statementNodes)) {
            for (JsonNode node : statementNodes) {
                statements.add(statementOf(node));
            }
        }

    } catch (Exception e) {
        String message = "Unable to generate policy object fron JSON string "
                + e.getMessage();
        throw new IllegalArgumentException(message, e);
    }
    policy.setStatements(statements);
    return policy;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:52,代码来源:JsonPolicyReader.java


示例6: JsonPolicyWriter

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
/**
 * Constructs a new instance of JSONPolicyWriter.
 */
public JsonPolicyWriter() {
    writer = new StringWriter();
    try {
        generator = Jackson.jsonGeneratorOf(writer);
    } catch (IOException ioe) {
        throw new SdkClientException(
                "Unable to instantiate JsonGenerator.", ioe);
    }

}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:JsonPolicyWriter.java


示例7: toString

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
@Override
public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append(getHttpMethod()).append(" ");
    builder.append(getEndpoint()).append(" ");
    String resourcePath = getResourcePath();

    if (resourcePath == null) {
        builder.append("/");
    }
    else {
        if (!resourcePath.startsWith("/")) {
            builder.append("/");
        }
        builder.append(resourcePath);
    }
    builder.append(" ");
    if (!getParameters().isEmpty()) {
        builder.append("Parameters: (")
               .append(Jackson.toJsonString(parameters));
    }

    if (!getHeaders().isEmpty()) {
        builder.append("Headers: (");
        for (String key : getHeaders().keySet()) {
            String value = getHeaders().get(key);
            builder.append(key).append(": ").append(value).append(", ");
        }
        builder.append(") ");
    }

    return builder.toString();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:34,代码来源:DefaultRequest.java


示例8: doGetInstanceInfo

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
static InstanceInfo doGetInstanceInfo(String json) {
    if (null != json) {
        try {
            InstanceInfo instanceInfo = Jackson.fromJsonString(json,
                    InstanceInfo.class);
            return instanceInfo;
        } catch (Exception e) {
            log.warn("Unable to parse dynamic EC2 instance info (" + json
                    + ") : " + e.getMessage(), e);
        }
    }
    return null;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:EC2MetadataUtils.java


示例9: testMultipleConditionKeysForConditionType

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
/**
 * Policies with multiple conditions that use the same comparison type must
 * be merged together in the JSON format, otherwise there will be two keys
 * with the same name and one will override the other.
 */
@Test
public void testMultipleConditionKeysForConditionType() throws Exception {
    Policy policy = new Policy();
    policy.withStatements(new Statement(Effect.Allow)
            .withResources(
                    new Resource(
                            "arn:aws:sqs:us-east-1:987654321000:MyQueue"))
            .withPrincipals(Principal.AllUsers)
            .withActions(new TestAction("foo"))
            .withConditions(
                    new StringCondition(StringComparisonType.StringNotLike,
                            "key1", "foo"),
                    new StringCondition(StringComparisonType.StringNotLike,
                            "key1", "bar")));

    JsonNode jsonPolicy = Jackson.jsonNodeOf(policy.toJson());

    JsonNode statementArray = jsonPolicy.get("Statement");
    assertEquals(statementArray.size(),1);
    JsonNode conditions = statementArray.get(0).get("Condition");
    assertEquals(conditions.size(),1);

    JsonNode stringLikeCondition = conditions.get(StringComparisonType.StringNotLike.toString());
    assertTrue(stringLikeCondition.has("key1"));
    assertFalse(stringLikeCondition.has("key2"));
    assertValidStatementIds(policy);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:33,代码来源:PolicyTest.java


示例10: testMultipleStatements

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
/**
 * Tests serializing a more complex policy object with multiple statements.
 */
@Test
public void testMultipleStatements() throws Exception {
    Policy policy = new Policy("S3PolicyId1");
    policy.withStatements(
            new Statement(Effect.Allow)
                    .withPrincipals(Principal.AllUsers)
                    .withActions(new TestAction("action1"))
                    .withResources(new Resource("resource"))
                    .withConditions(
                            new IpAddressCondition("192.168.143.0/24"),
                            new IpAddressCondition(
                                    IpAddressComparisonType.NotIpAddress,
                                    "192.168.143.188/32")),
            new Statement(Effect.Deny).withPrincipals(Principal.AllUsers)
                    .withActions(new TestAction("action2"))
                    .withResources(new Resource("resource"))
                    .withConditions(new IpAddressCondition("10.1.2.0/24")));

    JsonNode jsonPolicy = Jackson.jsonNodeOf(policy.toJson());
    assertTrue(jsonPolicy.has("Id"));

    JsonNode statementArray = jsonPolicy.get("Statement");
    assertEquals(statementArray.size(),2);
    assertValidStatementIds(policy);

    JsonNode statement;
    for (int i = 0; i < statementArray.size(); i++) {
        statement = statementArray.get(i);
        assertTrue(statement.has("Sid"));
        assertTrue(statement.has("Effect"));
        assertTrue(statement.has("Principal"));
        assertTrue(statement.has("Action"));
        assertTrue(statement.has("Resource"));
        assertTrue(statement.has("Condition"));
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:40,代码来源:PolicyTest.java


示例11: test

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test() throws Exception {
    InternalConfigJsonHelper b = new InternalConfigJsonHelper();
    b.setDefaultSigner(new SignerConfigJsonHelper("AWS4SignerType"));
    b.setServiceSigners(
        new JsonIndex<SignerConfigJsonHelper, SignerConfig>("cloudfront",
            new SignerConfigJsonHelper("CloudFrontSignerType")),
        new JsonIndex<SignerConfigJsonHelper, SignerConfig>("ec2",
                new SignerConfigJsonHelper("QueryStringSignerType")),
        new JsonIndex<SignerConfigJsonHelper, SignerConfig>("s3",
                new SignerConfigJsonHelper("S3SignerType"))
    );
    b.setRegionSigners(
            new JsonIndex<SignerConfigJsonHelper, SignerConfig>("cn-north-1",
                new SignerConfigJsonHelper("AWS4SignerType")));
    b.setServiceRegionSigners(
            new JsonIndex<SignerConfigJsonHelper, SignerConfig>("ec2/cn-north-1",
                new SignerConfigJsonHelper("AWS4SignerType")));
    b.setServiceRegionSigners(
            new JsonIndex<SignerConfigJsonHelper, SignerConfig>("cloudfront/cn-north-1",
                new SignerConfigJsonHelper("AWS4SignerType")));
    b.setHttpClients(
        new JsonIndex<HttpClientConfigJsonHelper, HttpClientConfig>(
            "AmazonMobiusClient",
                new HttpClientConfigJsonHelper("mobius-transform", "mobius-transform-endpoint")),
        new JsonIndex<HttpClientConfigJsonHelper, HttpClientConfig>(
            "AmazonAffineJavaClient",
                new HttpClientConfigJsonHelper("affine-transform", "affine-transform-endpoint")));
    String json = Jackson.toJsonPrettyString(b);
    p(json);
    InternalConfigJsonHelper b2 = Jackson.getObjectMapper().readValue(json, InternalConfigJsonHelper.class);
    String json2 = Jackson.toJsonPrettyString(b2);
    assertEquals(json, json2);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:36,代码来源:InternalConfigJsonHelperTest.java


示例12: test

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
@Test
public void test() throws Exception {
    p(Jackson.toJsonPrettyString(new SignerConfig("AWS3SignerType")));
    String json = Jackson.toJsonPrettyString(new SignerConfig("AWS3SignerType"));
    SignerConfig copy = Jackson.getObjectMapper().readValue(json, SignerConfigJsonHelper.class).build();
    String json2 = Jackson.toJsonPrettyString(copy);
    assertEquals(json, json2);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:9,代码来源:SignerConfigTest.java


示例13: toJsonStringEO

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
private String toJsonStringEO() {
    Map<String, String> map = new HashMap<String, String>();
    byte[] encryptedCEK = getEncryptedCEK();
    map.put(Headers.CRYPTO_KEY, Base64.encodeAsString(encryptedCEK));
    byte[] iv = cipherLite.getIV();
    map.put(Headers.CRYPTO_IV, Base64.encodeAsString(iv));
    map.put(Headers.MATERIALS_DESCRIPTION, kekMaterialDescAsJson());
    return Jackson.toJsonString(map);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:10,代码来源:ContentCryptoMaterial.java


示例14: kekMaterialDescAsJson

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
/**
 * Returns the key-encrypting-key material description as a non-null json
 * string;
 */
private String kekMaterialDescAsJson() {
    Map<String, String> kekMaterialDesc = getKEKMaterialsDescription();
    if (kekMaterialDesc == null)
        kekMaterialDesc = Collections.emptyMap();
    return Jackson.toJsonString(kekMaterialDesc);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:11,代码来源:ContentCryptoMaterial.java


示例15: ccmFromJson

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
private ContentCryptoMaterial ccmFromJson(String json) {
    @SuppressWarnings("unchecked")
    Map<String, String> instruction = Collections.unmodifiableMap(
            Jackson.fromJsonString(json, Map.class));
    return ContentCryptoMaterial.fromInstructionFile(
        instruction,
        kekMaterialsProvider,
        cryptoConfig.getCryptoProvider(),
        false,   // existing CEK not necessarily key-wrapped
        kms
    );
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:13,代码来源:S3CryptoModuleBase.java


示例16: decipherWithInstructionFile

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
private S3Object decipherWithInstructionFile(GetObjectRequest req,
        long[] desiredRange, long[] cryptoRange, S3ObjectWrapper retrieved,
        S3ObjectWrapper instructionFile) {
    ExtraMaterialsDescription extraMatDesc = NONE;
    boolean keyWrapExpected = isStrict();
    if (req instanceof EncryptedGetObjectRequest) {
        EncryptedGetObjectRequest ereq = (EncryptedGetObjectRequest)req;
        extraMatDesc = ereq.getExtraMaterialDescription();
        if (!keyWrapExpected)
            keyWrapExpected = ereq.isKeyWrapExpected();
    }
    String json = instructionFile.toJsonString();
    @SuppressWarnings("unchecked")
    Map<String, String> matdesc =
        Collections.unmodifiableMap(Jackson.fromJsonString(json, Map.class));
    ContentCryptoMaterial cekMaterial =
            ContentCryptoMaterial.fromInstructionFile(
                matdesc,
                kekMaterialsProvider,
                cryptoConfig.getCryptoProvider(),
                cryptoRange,   // range is sometimes necessary to compute the adjusted IV
                extraMatDesc,
                keyWrapExpected,
                kms
        );
    securityCheck(cekMaterial, retrieved);
    S3ObjectWrapper decrypted = decrypt(retrieved, cekMaterial, cryptoRange);
    // Adjust the output to the desired range of bytes.
    S3ObjectWrapper adjusted = adjustToDesiredRange(
            decrypted, desiredRange, matdesc);
    return adjusted.getS3Object();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:33,代码来源:S3CryptoModuleAE.java


示例17: extractInstanceType

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
private String extractInstanceType(String jobFlowJsonString, String targetInstanceRole) {
  JsonNode jobFlowJson = Jackson.jsonNodeOf(jobFlowJsonString);
  JsonNode instanceGroups = jobFlowJson.get("instanceGroups");

  for (int i = 0; i < instanceGroups.size(); i++) {
    JsonNode instanceGroup = instanceGroups.get(i);
    String instanceRole = instanceGroup.get("instanceRole").asText();
    if (targetInstanceRole.equalsIgnoreCase(instanceRole)) {
      String instanceType = instanceGroup.get("instanceType").asText();
      log.info(instanceRole + " instance type: " + instanceType);
      return instanceType;
    }
  }
  return null;
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:16,代码来源:ClusterTopologyNodeCapacityProvider.java


示例18: proxyIntegration

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
public static final String proxyIntegration(int statusCode, String[] headers, String body) {
	ObjectMapper mapper = Jackson.getObjectMapper();
	ObjectNode json = mapper.createObjectNode();
	
    json.put("statusCode", statusCode);
    
    ArrayNode array = mapper.createArrayNode();
    Arrays.stream(headers).forEach(header -> array.add(header));
    json.put("headers", array);

    json.put("body", body);

    return json.toString();
}
 
开发者ID:arun-gupta,项目名称:serverless,代码行数:15,代码来源:GatewayUtil.java


示例19: toJsonString

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
public String toJsonString() {
	try {
		return Jackson.getObjectMapper().writeValueAsString(this);
	} catch (JsonProcessingException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:efenderbosch,项目名称:spring-boot-aws-cloudsearch,代码行数:8,代码来源:Document.java


示例20: toString

import com.amazonaws.util.json.Jackson; //导入依赖的package包/类
@Override
public String toString() {
    return Jackson.toJsonString(this);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:5,代码来源:UnreliableFilterInputStream.java



注:本文中的com.amazonaws.util.json.Jackson类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PreemptionMessagePBImpl类代码示例发布时间:2022-05-22
下一篇:
Java HtmlTag类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap