Refine search
@VisibleForTesting void parseRetryLibrary(InputStream in) { if (in != null) { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); try { settings.put("retryLibrary", mapper.readValue(in, RetryStrategyLibrary.class)); } catch (IOException e) { throw new RuntimeException("Could not parse extension settings", e); } } }
@Override public Optional<JsonNode> apply(InputStream t) { try { YAMLParser parser = yamlFactory.createParser(t); return Optional.ofNullable(mapper.readTree(parser)); } catch (IOException e) { throw new RuntimeException("Error reading config data", e); } } }
@Override public YAMLFactory copy() { _checkInvalidCopy(YAMLFactory.class); return new YAMLFactory(this, null); }
protected static ObjectMapper createYaml() { YAMLFactory factory = new YAMLFactory(); factory.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER); factory.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES); factory.enable(YAMLGenerator.Feature.SPLIT_LINES); factory.enable(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS); return create(factory); }
private static String convertToJson(String yamlString) throws IOException { ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); Object obj = yamlReader.readValue(yamlString, Object.class); ObjectMapper jsonWriter = new ObjectMapper(); return jsonWriter.writeValueAsString(obj); }
/** * Load one or more data sets from a YAML manifest file. * @param file The path to the YAML manifest file. * @return The list of data sets. */ public static List<DataSet> load(Path file) throws IOException { YAMLFactory factory = new YAMLFactory(); ObjectMapper mapper = new ObjectMapper(factory); JsonNode node = mapper.readTree(file.toFile()); return fromJSON(node, file.toAbsolutePath().toUri()); }
public static ObjectMapper createYaml() { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // forward compatibility for the properties may go away in the future mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
public String convertPDToYaml(PropertyDefinition propertyDefinition) throws JsonParseException, JsonMappingException, IOException{ String yamlContent = null; if(propertyDefinition != null){ ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); yamlContent = mapper.writeValueAsString(propertyDefinition); } return yamlContent; }
private NetFlowV9FieldTypeRegistry(InputStream definitions) throws IOException { this(definitions, new ObjectMapper(new YAMLFactory())); }
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new SimpleModule() { @Override public void setupModule(SetupContext context) { Recipe recipe; try { recipe = mapper.readValue(stream, Recipe.class); } catch (IOException e) { binder.addError("'recipes' file %s couldn't parsed: %s", recipeConfig, e.getMessage());
private static ObjectMapper mapper() { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.setBase64Variant(Base64Variants.MODIFIED_FOR_URL); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.registerModule(new AfterburnerModule()); return mapper; }
private String convertToJsonIfNecessary(final PsiFile file) throws Exception { if (fileDetector.isMainSwaggerJsonFile(file) || fileDetector.isMainOpenApiJsonFile(file)) { return file.getText(); } final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final JsonNode jsonNode = mapper.readTree(file.getText()); return new ObjectMapper().writeValueAsString(jsonNode); } }
public MyYamlFile readYaml(final File file) { final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind return mapper.readValue(file, MyYamlFile.class); }
public static <T> void toYaml(T cfg, String path) throws IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter(); writer.writeValue(new File(path), cfg); }
@Override public IndexerConfiguration loadConfiguration() throws IOException { FileReader reader = new FileReader(configFile); final JsonNode node = mapper.readTree(yamlFactory.createParser(reader)); final IndexerConfiguration config = mapper.readValue(new TreeTraversingParser(node), IndexerConfiguration.class); // Close the file reader reader.close(); return config; }
/** * Creates a configured Jackson object mapper for parsing YAML */ public static ObjectMapper createObjectMapper() { YAMLFactory yamlFactory = new YAMLFactory(); yamlFactory.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false); return new ObjectMapper(yamlFactory); }
public static String dumpWithoutRuntimeStateAsYaml(HasMetadata obj) throws JsonProcessingException { ObjectMapper statelessMapper = new ObjectMapper(new YAMLFactory()); statelessMapper.addMixInAnnotations(ObjectMeta.class, ObjectMetaMixIn.class); statelessMapper.addMixInAnnotations(ReplicationController.class, StatelessReplicationControllerMixIn.class); return statelessMapper.writeValueAsString(obj); }
@Provides @Singleton @Named(YAML) public ObjectMapper providesYamlMapper() { final YAMLFactory yamlFactory = new YAMLFactory(); yamlFactory.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER); final ObjectMapper mapper = new ObjectMapper(yamlFactory); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.registerModule(new GuavaModule()); mapper.registerModule(new ProtobufModule()); return mapper; }
private void logArtifact(PropertyDefinition artifact) { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); String stringArtifact = null; try { stringArtifact = mapper.writeValueAsString(artifact); Log.info("Received PropertyDefinition:\n" + stringArtifact); } catch (JsonProcessingException e) { Log.error("Exception while logging artifact:", e); } } }
@Test public void testMergedConfigs() throws Exception { final InputStream mergedConfigStream = buildConfigurationSourceProvider(DEFAULT_PATH).open(OVERRIDE_PATH); final SingularityConfiguration mergedConfig = objectMapper.readValue(YAML_FACTORY.createParser(mergedConfigStream), SingularityConfiguration.class); assertEquals(10000, mergedConfig.getCacheTasksMaxSize()); assertEquals(500, mergedConfig.getCacheTasksInitialSize()); assertEquals(100, mergedConfig.getCheckDeploysEverySeconds()); assertEquals("baseuser", mergedConfig.getDatabaseConfiguration().get().getUser()); assertEquals("overridepassword", mergedConfig.getDatabaseConfiguration().get().getPassword()); }