List of usage examples for com.fasterxml.jackson.core.util ByteArrayBuilder ByteArrayBuilder
public ByteArrayBuilder()
From source file:org.nuxeo.client.api.marshaller.NuxeoRequestConverterFactory.java
@Override public RequestBody convert(T value) throws IOException { ByteArrayBuilder bb = new ByteArrayBuilder(); byte[] bytes; if (nuxeoMarshaller != null) { JsonGenerator jg = objectMapper.getFactory().createGenerator(bb, JsonEncoding.UTF8); nuxeoMarshaller.write(jg, value); bytes = bb.toByteArray();//from www . j a v a 2s. c om } else { bytes = adapter.writeValueAsBytes(value); } return RequestBody.create(ConstantsV1.APPLICATION_JSON_CHARSET_UTF_8, bytes); }
From source file:gaffer.jsonserialisation.JSONSerialiser.java
/** * Serialises an object.//from w w w . j av a2 s . c o m * * @param object the object to be serialised * @param prettyPrint true if the object should be serialised with pretty printing * @return the provided object serialised (with pretty printing) into bytes * @throws SerialisationException if the object fails to serialise */ public byte[] serialise(final Object object, final boolean prettyPrint) throws SerialisationException { final ByteArrayBuilder byteArrayBuilder = new ByteArrayBuilder(); try { serialise(object, JSON_FACTORY.createGenerator(byteArrayBuilder, JsonEncoding.UTF8), prettyPrint); } catch (IOException e) { throw new SerialisationException(e.getMessage(), e); } return byteArrayBuilder.toByteArray(); }
From source file:uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser.java
/** * Serialises an object./* w w w. ja v a 2 s . c om*/ * * @param object the object to be serialised * @param prettyPrint true if the object should be serialised with pretty printing * @param fieldsToExclude optional property names to exclude from the json * @return the provided object serialised (with pretty printing) into bytes * @throws SerialisationException if the object fails to serialise */ public byte[] serialise(final Object object, final boolean prettyPrint, final String... fieldsToExclude) throws SerialisationException { final ByteArrayBuilder byteArrayBuilder = new ByteArrayBuilder(); try { serialise(object, JSON_FACTORY.createGenerator(byteArrayBuilder, JsonEncoding.UTF8), prettyPrint, fieldsToExclude); } catch (final IOException e) { throw new SerialisationException(e.getMessage(), e); } return byteArrayBuilder.toByteArray(); }