Example usage for com.fasterxml.jackson.databind ObjectMapper ObjectMapper

List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectMapper ObjectMapper.

Prototype

protected ObjectMapper(ObjectMapper src) 

Source Link

Document

Copy-constructor, mostly used to support #copy .

Usage

From source file:org.redisson.codec.CborJacksonCodec.java

public CborJacksonCodec() {
    super(new ObjectMapper(new CBORFactory()));
}

From source file:com.chiralBehaviors.slp.hive.hardtack.configuration.AggregatorConfiguration.java

public static AggregatorConfiguration fromYaml(InputStream yaml)
        throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    return mapper.readValue(yaml, AggregatorConfiguration.class);
}

From source file:org.apache.myriad.scheduler.resource.TestResourceOfferContainer.java

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    cfg = mapper.readValue(/* w  w  w .  j  a va  2 s  .  com*/
            Thread.currentThread().getContextClassLoader().getResource("myriad-config-test-default.yml"),
            MyriadConfiguration.class);
}

From source file:org.redisson.codec.AvroJacksonCodec.java

public AvroJacksonCodec() {
    super(new ObjectMapper(new AvroFactory()));
}

From source file:org.redisson.codec.SmileJacksonCodec.java

public SmileJacksonCodec() {
    super(new ObjectMapper(new SmileFactory()));
}

From source file:org.redisson.codec.MsgPackJacksonCodec.java

public MsgPackJacksonCodec() {
    super(new ObjectMapper(new MessagePackFactory()));
}

From source file:de.undercouch.bson4jackson.serializers.BsonSerializersTest.java

private static Object generateAndParse(Object data) throws Exception {
    Map<String, Object> m = new LinkedHashMap<String, Object>();
    m.put("data", data);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    ObjectMapper om = new ObjectMapper(new BsonFactory());
    om.registerModule(new BsonModule());
    om.writeValue(baos, m);/*  w w  w .j  a  v  a 2s .  c  om*/

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject bo = decoder.readObject(bais);

    return bo.get("data");
}

From source file:com.hellblazer.glassHouse.discovery.HubConfiguration.java

public static HubConfiguration fromYaml(InputStream yaml)
        throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    mapper.registerModule(new DiscoveryModule());
    return mapper.readValue(yaml, HubConfiguration.class);
}

From source file:com.raythos.sentilexo.persistence.cql.PersistedEntity.java

public static byte[] toBinaryJSon(PersistedEntity item) {
    try {//from  w  w  w  . j  ava 2  s  .  c  o  m
        SmileFactory f = new SmileFactory();
        f.configure(SmileParser.Feature.REQUIRE_HEADER, true);
        ObjectMapper mapper = new ObjectMapper(f);
        mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
        byte[] result = mapper.writeValueAsBytes(item);
        return result;
    } catch (JsonProcessingException ex) {
        Logger.getLogger(QueryResultItemMapper.class.getName()).log(Level.SEVERE, null, ex);
        return null;

    }
}

From source file:org.fasterxml.jackson.tc.TreeTest.java

static <T extends Enum<T>, K> K transcodeFromMap(Map<T, Object> configuration,
        TypeReference<K> configurationType) {
    ObjectMapper mapper = TestEnumModule.setupObjectMapper(new ObjectMapper(new YAMLFactory()));
    JsonNode tree = mapper.valueToTree(configuration);
    try {/*from  ww w  .  j  a va  2  s  . c  om*/
        return mapper.readerFor(configurationType).readValue(tree);
    } catch (IOException e) {
        throw new RuntimeException(
                "Failed to map configuration map to object of type " + configurationType.toString(), e);
    }
}