Search in sources :

Example 1 with YAMLFactory

use of com.fasterxml.jackson.dataformat.yaml.YAMLFactory in project elasticsearch by elastic.

the class YamlXContentTests method testBigInteger.

public void testBigInteger() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    JsonGenerator generator = new YAMLFactory().createGenerator(os);
    doTestBigInteger(generator, os);
}
Also used : JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with YAMLFactory

use of com.fasterxml.jackson.dataformat.yaml.YAMLFactory in project KaiZen-OpenAPI-Editor by RepreZen.

the class Model method parse.

public static Model parse(CompositeSchema schema, JsonNode document) {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    String text = null;
    try {
        text = mapper.writeValueAsString(document);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return parseYaml(schema, text);
}
Also used : YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with YAMLFactory

use of com.fasterxml.jackson.dataformat.yaml.YAMLFactory in project trex-stateless-gui by cisco-system-traffic-generator.

the class TrafficProfile method getTrafficProfile.

/**
     * @param yamlFile File containing the Traffic Profile Yaml.
     * @return parsed Yaml file
     * @throws java.io.IOException
     */
public Profile[] getTrafficProfile(File yamlFile) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    Profile[] trafficProfileArray = mapper.readValue(yamlFile, Profile[].class);
    int i = 0;
    for (Profile profile : trafficProfileArray) {
        Map<String, Object> streamAdditionalProperties = profile.getStream().getAdditionalProperties();
        if (streamAdditionalProperties.containsKey("vm")) {
            profile.getStream().setVmRaw(streamAdditionalProperties.get("vm").toString());
        }
        if (streamAdditionalProperties.containsKey("rx_stats")) {
            profile.getStream().setRxStatsRaw(streamAdditionalProperties.get("rx_stats").toString());
        }
        // Check the Binary is in the Yaml File
        if (profile.getStream().getPacket().getBinary() == null) {
            String absolutePath = yamlFile.getAbsolutePath();
            String filePath = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator));
            String pacpFile = profile.getStream().getPacket().getPcap();
            String encodedPcap = encodePcapFile(filePath + File.separator + pacpFile);
            profile.getStream().getPacket().setBinary(encodedPcap);
        }
        profile.getStream().getPacket().setPcap(null);
        if (profile.getName() == null) {
            profile.setName("Stream" + i++);
        }
    }
    return trafficProfileArray;
}
Also used : YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Profile(com.exalttech.trex.remote.models.profiles.Profile)

Example 4 with YAMLFactory

use of com.fasterxml.jackson.dataformat.yaml.YAMLFactory in project jvm-serializers by eishay.

the class JacksonYAMLDatabind method register.

public static void register(TestGroups groups) {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind<MediaContent>("yaml/jackson/databind", MediaContent.class, mapper), new SerFeatures(SerFormat.JSON, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) MediaContent(data.media.MediaContent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with YAMLFactory

use of com.fasterxml.jackson.dataformat.yaml.YAMLFactory in project PatchLib by mariotaku.

the class PatchLibApplication method startProcess.

private boolean startProcess(File inFile, File outFile, CommandLine cmdLine) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    final ProcessingRules conf = new ProcessingRules();
    conf.setRules(new HashMap<String, PatchClassInfo>());
    for (File rulesFile : getFiles(cmdLine.getOptionValue("rules"))) {
        final Map<String, PatchClassInfo> rulesMap = mapper.readValue(rulesFile, new TypeReference<Map<String, PatchClassInfo>>() {
        });
        conf.addRules(rulesMap);
    }
    try (InputStream is = new FileInputStream(inFile);
        OutputStream os = new FileOutputStream(outFile)) {
        final LibraryProcessor.CommandLineOptions options = getOptions(cmdLine);
        options.setSourceFilePath(inFile.getAbsolutePath());
        final LibraryProcessor processor = LibraryProcessor.get(is, os, inFile.getName(), conf, options);
        if (processor == null) {
            throw new UnsupportedOperationException("Unsupported library " + inFile);
        }
        return processor.process();
    }
}
Also used : LibraryProcessor(org.mariotaku.patchlib.common.processor.LibraryProcessor) PatchClassInfo(org.mariotaku.patchlib.common.model.PatchClassInfo) ProcessingRules(org.mariotaku.patchlib.common.model.ProcessingRules) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Profile (com.exalttech.trex.remote.models.profiles.Profile)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 MediaContent (data.media.MediaContent)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PatchClassInfo (org.mariotaku.patchlib.common.model.PatchClassInfo)1 ProcessingRules (org.mariotaku.patchlib.common.model.ProcessingRules)1 LibraryProcessor (org.mariotaku.patchlib.common.processor.LibraryProcessor)1