List of usage examples for com.fasterxml.jackson.dataformat.cbor CBORFactory CBORFactory
public CBORFactory()
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 v a 2 s . c o 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:org.redisson.codec.CborJacksonCodec.java
public CborJacksonCodec() { super(new ObjectMapper(new CBORFactory())); }
From source file:org.redisson.codec.CborJacksonCodec.java
public CborJacksonCodec(ClassLoader classLoader) { super(createObjectMapper(classLoader, new ObjectMapper(new CBORFactory()))); }
From source file:sawtooth.examples.intkey.IntegerKeyHandler.java
/** * constructor./*from w ww. j a v a2 s .c om*/ */ public IntegerKeyHandler() { CBORFactory factory = new CBORFactory(); this.mapper = new ObjectMapper(factory); try { this.intkeyNameSpace = Utils.hash512(this.transactionFamilyName().getBytes("UTF-8")).substring(0, 6); } catch (UnsupportedEncodingException usee) { usee.printStackTrace(); this.intkeyNameSpace = ""; } }
From source file:sawtooth.examples.jvmsc.JvmScHandler.java
public JvmScHandler() { CBORFactory factory = new CBORFactory(); this.mapper = new ObjectMapper(factory); }
From source file:com.diffeo.dossier.fc.FeatureCollectionTest.java
@Test public void serializeEmptyFCCbor() throws JsonProcessingException { FeatureCollection fc = new FeatureCollection(); CBORFactory cborf = new CBORFactory(); ObjectMapper mapper = new ObjectMapper(cborf); byte[] cbor = mapper.writeValueAsBytes(fc); byte[] ref = { (byte) 0x9f, // array of ??? items (byte) 0xbf, // map of ??? items (byte) 0x61, 0x76, // string "v" (byte) 0x64, 0x66, 0x63, 0x30, 0x31, // string "fc01" (byte) 0xff, // end metadata map (byte) 0xbf, // map of ??? items (byte) 0xff, // end content map (byte) 0xff, // end array };/* w w w .j a v a 2 s . c o m*/ assertThat(cbor, is(equalTo(ref))); }
From source file:com.diffeo.dossier.fc.StringCounterTest.java
@Test public void serializeToCbor() throws JsonProcessingException { StringCounter name = new StringCounter(); name.add("John Smith", 1); CBORFactory cborf = new CBORFactory(); ObjectMapper mapper = new ObjectMapper(cborf); byte[] cbor = mapper.writeValueAsBytes(name); byte[] ref = { (byte) 0xd9, (byte) 0xd9, (byte) 0xf8, // tag 55080 (byte) 0xbf, // map of ??? items (byte) 0x6a, 0x4a, 0x6f, 0x68, 0x6e, 0x20, 0x53, 0x6d, 0x69, 0x74, 0x68, // string "John Smith" (byte) 0x01, // integer 1 (byte) 0xff, // end map };//from w ww. j a v a2s . c om assertThat(cbor, is(equalTo(ref))); }
From source file:com.diffeo.dossier.fc.StringCounterTest.java
@Test public void deserializeFromCbor() throws IOException { CBORFactory cborf = new CBORFactory(); ObjectMapper mapper = new ObjectMapper(cborf); byte[] ref = { (byte) 0xd9, (byte) 0xd9, (byte) 0xf8, // tag 55080 (byte) 0xa2, // map of 2 items (byte) 0x61, 0x61, // string "a" (byte) 0x01, // integer 1 (byte) 0x62, 0x62, 0x63, // string "bc" (byte) 0x11, // integer 17 };//from w w w . j a v a 2s .c o m StringCounter name = mapper.readValue(ref, StringCounter.class); assertThat(name.isReadOnly(), is(false)); assertThat(name.getStrings().size(), is(2)); assertThat(name.getStrings(), hasEntry("a", new Integer(1))); assertThat(name.getStrings(), hasEntry("bc", new Integer(17))); }
From source file:com.diffeo.dossier.fc.FeatureCollectionTest.java
@Test public void deserializeEmptyFCCbor() throws IOException { CBORFactory cborf = new CBORFactory(); ObjectMapper mapper = new ObjectMapper(cborf); // NB: This is a more compact form I expect a sensible // writer to spit out byte[] ref = { (byte) 0x82, // array of 2 items (byte) 0xa1, // map of 1 item (byte) 0x61, 0x76, // string "v" (byte) 0x64, 0x66, 0x63, 0x30, 0x31, // string "fc01" (byte) 0xa0, // map of 0 items };/*w ww. jav a2 s . c o m*/ FeatureCollection fc = mapper.readValue(ref, FeatureCollection.class); assertThat(fc, is(notNullValue())); assertThat(fc.isReadOnly(), is(false)); assertThat(fc.getFeatures().isEmpty(), is(true)); }
From source file:com.diffeo.dossier.fc.FeatureCollectionTest.java
@Test public void deserializeEmptyCbor() throws IOException { CBORFactory cborf = new CBORFactory(); ObjectMapper mapper = new ObjectMapper(cborf); byte[] ref = { (byte) 0x80, // array of 0 items };/* w w w . j a va2s . c o m*/ try { mapper.readValue(ref, FeatureCollection.class); assertThat("an empty array", is("rejected")); } catch (JsonMappingException e) { // expected case } }