List of usage examples for com.fasterxml.jackson.dataformat.smile SmileFactory SmileFactory
public SmileFactory()
From source file:com.basistech.rosette.dm.json.array.CompareJsons.java
public static void main(String[] args) throws Exception { File plenty = new File(args[0]); System.out.println(String.format("Original file length %d", plenty.length())); ObjectMapper inputMapper = AnnotatedDataModelModule.setupObjectMapper(new ObjectMapper()); AnnotatedText[] texts = inputMapper.readValue(plenty, AnnotatedText[].class); System.out.println(String.format("%d documents", texts.length)); runWithFormat(texts, new FactoryFactory() { @Override/*from w ww. j a va 2 s. co m*/ public JsonFactory newFactory() { return new JsonFactory(); } }, "Plain"); runWithFormat(texts, new FactoryFactory() { @Override public JsonFactory newFactory() { return new SmileFactory(); } }, "SMILE"); runWithFormat(texts, new FactoryFactory() { @Override public JsonFactory newFactory() { return new CBORFactory(); } }, "CBOR"); }
From source file:de.stadtrallye.rallyesoft.util.converters.Serialization.java
public static ObjectMapper getSmileInstance() { if (smileMapper == null) { smileMapper = new ObjectMapper(new SmileFactory()); }/*from w w w. ja va 2 s . c o m*/ return smileMapper; }
From source file:net.anyflow.lannister.serialization.JsonSerializer.java
public static <V> Serializer makeBinary(final Class<V> type) { return new JsonSerializer<>(type, HazelcastSerializationConstants.TYPEID_JSON_BINARY, new SmileFactory()); }
From source file:com.raythos.sentilexo.persistence.cql.PersistedEntity.java
public static byte[] toBinaryJSon(PersistedEntity item) { try {/* w w w . j a va2 s . co 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.redisson.codec.SmileJacksonCodec.java
public SmileJacksonCodec() { super(new ObjectMapper(new SmileFactory())); }
From source file:com.proofpoint.http.client.SmileBodyGenerator.java
public static <T> SmileBodyGenerator<T> smileBodyGenerator(JsonCodec<T> jsonCodec, T instance) { ObjectMapper objectMapper = OBJECT_MAPPER_SUPPLIER.get(); ByteArrayOutputStream out = new ByteArrayOutputStream(); JsonGenerator jsonGenerator;/*from www .j a v a2 s . c om*/ try { jsonGenerator = new SmileFactory().createGenerator(out); } catch (IOException e) { throw propagate(e); } Type genericType = jsonCodec.getType(); // 04-Mar-2010, tatu: How about type we were given? (if any) JavaType rootType = null; if (genericType != null && instance != null) { // 10-Jan-2011, tatu: as per [JACKSON-456], it's not safe to just force root // type since it prevents polymorphic type serialization. Since we really // just need this for generics, let's only use generic type if it's truly // generic. if (genericType.getClass() != Class.class) { // generic types are other implementations of 'java.lang.reflect.Type' // This is still not exactly right; should root type be further // specialized with 'value.getClass()'? Let's see how well this works before // trying to come up with more complete solution. rootType = objectMapper.getTypeFactory().constructType(genericType); // 26-Feb-2011, tatu: To help with [JACKSON-518], we better recognize cases where // type degenerates back into "Object.class" (as is the case with plain TypeVariable, // for example), and not use that. // if (rootType.getRawClass() == Object.class) { rootType = null; } } } try { if (rootType != null) { objectMapper.writerWithType(rootType).writeValue(jsonGenerator, instance); } else { objectMapper.writeValue(jsonGenerator, instance); } } catch (IOException e) { throw new IllegalArgumentException( String.format("%s could not be converted to SMILE", instance.getClass().getName()), e); } return new SmileBodyGenerator<>(out.toByteArray()); }
From source file:org.redisson.codec.SmileJacksonCodec.java
public SmileJacksonCodec(ClassLoader classLoader) { super(createObjectMapper(classLoader, new ObjectMapper(new SmileFactory()))); }
From source file:com.github.lburgazzoli.hazelcast.serialization.json.JsonSerializer.java
public static <V> Serializer makeBinary(final Class<V> type) { return new JsonSerializer<>(type, HzSerializationConstants.TYPEID_JSON_BINARY, new SmileFactory()); }
From source file:com.proofpoint.http.client.TestSmileBodyGenerator.java
@Override protected Object decodeBody(byte[] body) throws Exception { ObjectMapper mapper = new ObjectMapper(new SmileFactory()); return mapper.readValue(body, Object.class); }
From source file:org.graylog.plugins.usagestatistics.providers.SmileObjectMapperProvider.java
public SmileObjectMapperProvider() { final SmileFactory smileFactory = new SmileFactory().disable(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT) .enable(SmileGenerator.Feature.WRITE_END_MARKER); objectMapper = new ObjectMapper(smileFactory).setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE) .registerModule(new JodaModule()).registerModule(new GuavaModule()); }