io.syndesis.core.Json.mapper()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中io.syndesis.core.Json.mapper()方法的一些代码示例,展示了Json.mapper()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.mapper()方法的具体详情如下:
包路径:io.syndesis.core.Json
类名称:Json
方法名:mapper

Json.mapper介绍

暂无

代码示例

代码示例来源:origin: io.syndesis/extension-converter

private ObjectNode marshal(Extension extension) {
  return Json.mapper().convertValue(extension, ObjectNode.class);
}

代码示例来源:origin: io.syndesis/extension-converter

private Extension unmarshal(JsonNode node) {
  return Json.mapper().convertValue(node, Extension.class);
}

代码示例来源:origin: io.syndesis/connector-generator

public static String serializeJson(final ObjectNode schemaNode) {
  try {
    return Json.mapper().writeValueAsString(schemaNode);
  } catch (final JsonProcessingException e) {
    throw new IllegalStateException("Unable to serialize JSON schema", e);
  }
}

代码示例来源:origin: io.syndesis/connector-generator

public static String serialize(final Swagger swagger) {
  try {
    return Json.mapper().writeValueAsString(swagger);
  } catch (final JsonProcessingException e) {
    throw new IllegalStateException("Unable to serialize Swagger specification", e);
  }
}

代码示例来源:origin: io.syndesis/db-logging

private <T> T dbGet(Class<T> type, String path, GetOptions options) throws IOException {
  byte[] data = jsonDB.getAsByteArray(path, options);
  if (data == null) {
    return null;
  }
  return Json.mapper().readValue(data, type);
}

代码示例来源:origin: io.syndesis/connector-generator

private static JsonNode parseJsonSchema(final String schema) {
  try {
    return Json.mapper().readTree(schema);
  } catch (final IOException e) {
    throw new IllegalStateException("Unable to parse given JSON schema: " + StringUtils.abbreviate(schema, 100), e);
  }
}

代码示例来源:origin: io.syndesis/dao

public List<ModelData<?>> readDataFromString(String jsonText) throws JsonParseException, JsonMappingException, IOException {
  String json = findAndReplaceTokens(jsonText,System.getenv());
  return Json.mapper().readValue(json, MODEL_DATA_TYPE);
}
/**

代码示例来源:origin: io.syndesis/connector-generator

private static JsonNode createSchemaFromModelImpl(final Model schema) {
  try {
    final String schemaString = Json.mapper().writeValueAsString(schema);
    return parseJsonSchema(schemaString);
  } catch (final JsonProcessingException e) {
    throw new IllegalStateException("Unable to serialize given JSON specification in response schema: " + schema, e);
  }
}

代码示例来源:origin: io.syndesis/db-logging

public void setPodLogState(String podName, PodLogState state) throws IOException {
  jsonDB.set("/logs/pods/" + podName, Json.mapper().writeValueAsBytes(state));
}

代码示例来源:origin: io.syndesis/connector-generator

/* default */ static String resolve(final String specification) throws Exception {
  final String specificationToUse;
  if (specification.toLowerCase().startsWith("http")) {
    specificationToUse = RemoteUrl.urlToString(specification, null);
  } else {
    specificationToUse = specification;
  }
  final JsonNode node = convertToJson(specificationToUse);
  return Json.mapper().writeValueAsString(node);
}

代码示例来源:origin: io.syndesis/extension-converter

private Extension doGetExtension(InputStream binaryExtension) throws IOException {
  Optional<InputStream> entry = readPath(binaryExtension, MANIFEST_LOCATION);
  if (!entry.isPresent()) {
    throw new IllegalArgumentException("Cannot find manifest file (" + MANIFEST_LOCATION + ") inside JAR");
  }
  JsonNode tree = Json.mapper().readTree(entry.get());
  Extension extension = ExtensionConverter.getDefault().toInternalExtension(tree);
  if (extension == null) {
    throw new IllegalArgumentException("Cannot extract Extension from manifest file (" + MANIFEST_LOCATION + ") inside JAR");
  }
  return extension;
}

代码示例来源:origin: io.syndesis/integration-runtime

protected IntegrationDeployment loadDeployment() throws IOException {
  final IntegrationDeployment deployment;
  try (InputStream is = ResourceHelper.resolveResourceAsInputStream(getContext().getClassResolver(), configurationUri)) {
    if (is != null) {
      LOGGER.info("Loading integration from: {}", configurationUri);
      deployment = Json.mapper().readValue(is, IntegrationDeployment.class);
    } else {
      throw new IllegalStateException("Unable to load deployment: " + configurationUri);
    }
  }
  return deployment;
}

代码示例来源:origin: io.syndesis/connector-generator

private static JsonNode createSchemaFromProperty(final String specification, final Property schema) {
  if (schema instanceof MapProperty) {
    try {
      final String schemaString = Json.mapper().writeValueAsString(schema);
      return parseJsonSchema(schemaString);
    } catch (final JsonProcessingException e) {
      throw new IllegalStateException("Unable to serialize/read given JSON specification in response schema: " + schema, e);
    }
  } else if (schema instanceof StringProperty) {
    return null;
  }
  final String reference = determineSchemaReference(schema);
  final String title = Optional.ofNullable(schema.getTitle()).orElse(reference.replaceAll("^.*/", ""));
  return createSchemaFromReference(specification, title, reference);
}

代码示例来源:origin: io.syndesis/connector-generator

private static DataShape createShapeFromProperty(final String specification, final Property schema) {
  if (schema instanceof MapProperty) {
    try {
      final String schemaString = Json.mapper().writeValueAsString(schema);
      return new DataShape.Builder().kind("json-schema").specification(schemaString).build();
    } catch (final JsonProcessingException e) {
      throw new IllegalStateException("Unable to serialize given JSON specification in response schema: " + schema, e);
    }
  } else if (schema instanceof StringProperty) {
    return DATA_SHAPE_NONE;
  }
  final String reference = determineSchemaReference(schema);
  final String title = Optional.ofNullable(schema.getTitle()).orElse(reference.replaceAll("^.*/", ""));
  return createShapeFromReference(specification, title, reference);
}

代码示例来源:origin: io.syndesis/jsondb

@Override
public T fetch(String id) {
  try {
    String dbPath = getCollectionPath()+"/:"+id;
    byte[] json = jsondb.getAsByteArray(dbPath);
    if( json==null || json.length == 0 ) {
      return null;
    }
    return Json.mapper().readValue(json, getType());
  } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) {
    throw SyndesisServerException.launderThrowable(e);
  }
}

代码示例来源:origin: io.syndesis/jsondb

@Override
public T create(T entity) {
  try {
    String dbPath = getCollectionPath()+"/:"+entity.getId().get();
    // Only create if it did not exist.
    if( jsondb.exists(dbPath) ) {
      return null;
    }
    byte[] json = Json.mapper().writeValueAsBytes(entity);
    jsondb.set(dbPath, json);
    return entity;
  } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) {
    throw SyndesisServerException.launderThrowable(e);
  }
}

代码示例来源:origin: io.syndesis/jsondb

@Override
public T update(T entity) {
  try {
    T previousValue = this.fetch(entity.getId().get());
    // Only update if the entity existed.
    if( previousValue !=null ) {
      String dbPath = getCollectionPath()+"/:"+entity.getId().get();
      byte[] json = Json.mapper().writeValueAsBytes(entity);
      jsondb.set(dbPath, json);
    }
    return previousValue;
  } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException|IOException e) {
    throw SyndesisServerException.launderThrowable(e);
  }
}

代码示例来源:origin: io.syndesis/extension-converter

@Test
@Ignore("Used to generate the initial extension definition")
public void generateBaseExtensionDefinition() throws Exception {
  ObjectMapper mapper = Json.mapper();
  JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
  com.fasterxml.jackson.module.jsonSchema.JsonSchema schema = schemaGen.generateSchema(Extension.class);
  System.out.println(mapper.writeValueAsString(schema));
}

代码示例来源:origin: io.syndesis/model

@Test
  public void testTrimming() throws IOException {

    final SortedSet<String> tags = new TreeSet<>();
    tags.add("");
    tags.add(" tag");
    tags.add("\tTaggy McTagface\t");

    final Integration original = new Integration.Builder()
        .id("test")
        .name("  some-name\t").description("")
        .tags(tags)
        .desiredStatus(IntegrationDeploymentState.Draft)
        .build();

    final Integration created = Json.mapper().readValue(Json.mapper().writeValueAsBytes(original), Integration.class);

    assertThat(created.getName()).isEqualTo("some-name");
    assertThat(created.getDescription()).isNotPresent();
    assertThat(created.getTags()).containsExactly("Taggy McTagface", "tag");

  }
}

代码示例来源:origin: io.syndesis/extension-converter

@Test
public void addSchemaVersionInPublicModelExtensionTest() throws ProcessingException {
  String syndesisExtensionSchema = "/syndesis/syndesis-extension-definition-schema.json";
  JsonSchema schema = JsonSchemaFactory.byDefault().getJsonSchema("resource:" + syndesisExtensionSchema);
  ExtensionConverter converter = new DefaultExtensionConverter();
  ObjectNode tree = Json.mapper().createObjectNode()
      .put("extensionId", "my-extension")
      .put("name", "Name")
      .put("description", "Description")
      .put("version", "1.0.0");
  ProcessingReport report = schema.validate(tree);
  assertFalse(report.toString(), report.iterator().hasNext());
  Extension extension = converter.toInternalExtension(tree);
  assertEquals(ExtensionConverter.getCurrentSchemaVersion(), extension.getSchemaVersion());
}

相关文章

微信公众号

最新文章

更多