Example usage for com.fasterxml.jackson.dataformat.cbor CBORGenerator writeObject

List of usage examples for com.fasterxml.jackson.dataformat.cbor CBORGenerator writeObject

Introduction

In this page you can find the example usage for com.fasterxml.jackson.dataformat.cbor CBORGenerator writeObject.

Prototype

@Override
    public void writeObject(Object value) throws IOException, JsonProcessingException 

Source Link

Usage

From source file:com.pushtechnology.diffusion.examples.ControlClientUpdatingJSONTopics.java

/**
 * Convert a given map to a JSON object.
 *//*from  www  .  ja v  a 2 s.c  om*/
private JSON mapToJSON(Map<String, String> values) throws IOException {
    // Use the third-party Jackson library to write out the values map as a
    // CBOR-format binary.
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final CBORGenerator generator = cborFactory.createGenerator(baos);
    generator.writeObject(values);
    return jsonDataType.readValue(baos.toByteArray());
}