@Override public RequestBody convert(T value) throws IOException { byte[] bytes = adapter.writeValueAsBytes(value); return RequestBody.create(MEDIA_TYPE, bytes); } }
public static byte[] objectToBytes(Object object) throws JsonProcessingException { return DEFAULT_WRITER.writeValueAsBytes(object); }
private byte[] serialize(MonitoringEvent event) throws IOException { return writer.writeValueAsBytes(event); }
@Override public RequestBody convert(T value) throws IOException { byte[] bytes = adapter.writeValueAsBytes(value); return RequestBody.create(MEDIA_TYPE, bytes); } }
@SneakyThrows private ByteBuffer serialize(IN input) { return ByteBuffer.wrap(writer.writeValueAsBytes(input)); }
private byte[] writeObject(Object o) { try { return this.mapper.writer().writeValueAsBytes(o); } catch (JsonProcessingException e) { throw new AssertionError(e); } }
Response gotError(Exception e) throws IOException { return Response.serverError() .type(contentType) .entity(newOutputWriter(false).writeValueAsBytes(QueryInterruptedException.wrapIfNeeded(e))) .build(); } }
public static byte[] sha1digest(final Map<String, ?> obj) throws IOException { final byte[] bytes = NORMALIZING_OBJECT_WRITER.writeValueAsBytes(obj); return Hash.sha1digest(bytes); } }
private static <T> ByteString serialize(ObjectWriter objectWriter, T object) { try { return ByteString.of(objectWriter.writeValueAsBytes(object)); } catch (JsonProcessingException e) { throw Throwables.propagate(e); } }
@Override public byte[] writeValueAsBytes(Object value) throws JsonProcessingException { return writerFor(type).with(schema).writeValueAsBytes(value); }
@Override public byte[] writeValueAsBytes(Object value) throws JsonProcessingException { return writerFor(type).with(schema).writeValueAsBytes(value); }
@Override public void write(final Map<String, Object> row) throws IOException { final byte[] bytes; if (shouldWriteHeader) { // Write the header once (mapper.writer will clone the writer). Add a small marker in front of the header // to easily split it write(String.format("-- %s ", currentTableName).getBytes()); bytes = mapper.writer(currentCSVSchema.withHeader()).writeValueAsBytes(row); shouldWriteHeader = false; } else { bytes = writer.writeValueAsBytes(row); } write(bytes); }
if (mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)) { if (prettyPrint) { out.write(Json.pretty().writeValueAsBytes(data)); } else { out.write(Json.mapper().writeValueAsBytes(data)); headers.add("Content-Type", "application/yaml"); if (prettyPrint) { out.write(Yaml.pretty().writeValueAsBytes(data)); } else { out.write(Yaml.mapper().writeValueAsBytes(data)); headers.add("Content-Type", "application/json"); if (prettyPrint) { out.write(Json.pretty().writeValueAsBytes(data)); } else { out.write(Json.mapper().writeValueAsBytes(data));
protected void renderValue(final Object value, final Renderer.Context ctx) throws Exception { // use UTF-8 and get byte version final byte[] bytes; if (value instanceof JacksonView) { final JacksonView viewResponse = (JacksonView) value; bytes = mapper .writerWithView(viewResponse.view) .writeValueAsBytes(viewResponse.data); } else { bytes = mapper.writeValueAsBytes(value); } ctx.length(bytes.length) .send(bytes); }
@Override public void serverStarting(Server server) throws Exception { final ServerConfig config = server.config(); final List<VirtualHost> virtualHosts = config.findVirtualHosts(DocService.this); final List<ServiceConfig> services = config.serviceConfigs().stream() .filter(se -> virtualHosts.contains(se.virtualHost())) .collect(toImmutableList()); ServiceSpecification spec = generate(services); spec = addDocStrings(spec, services); spec = addExamples(spec); vfs(SPECIFICATION_INDEX).setContent(jsonMapper.writerWithDefaultPrettyPrinter() .writeValueAsBytes(spec)); } });
.addHeader(HttpHeaders.Names.ACCEPT, MediaType.APPLICATION_JSON) .addHeader(HttpHeaders.Names.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setContent(requestBodyWriter.writeValueAsBytes(newRequests)), responseHandler, new Duration(config.getHttpLoadQueuePeonHostTimeout().getMillis() + 5000)
@Override public <T> SerializedObject<T> serialize(Object object, Class<T> expectedRepresentation) { try { if (String.class.equals(expectedRepresentation)) { //noinspection unchecked return new SimpleSerializedObject<>((T) getWriter().writeValueAsString(object), expectedRepresentation, typeForClass(ObjectUtils.nullSafeTypeOf(object))); } byte[] serializedBytes = getWriter().writeValueAsBytes(object); T serializedContent = converter.convert(serializedBytes, expectedRepresentation); return new SimpleSerializedObject<>(serializedContent, expectedRepresentation, typeForClass(ObjectUtils.nullSafeTypeOf(object))); } catch (JsonProcessingException e) { throw new SerializationException("Unable to serialize object", e); } }
ServerTestHelper.MAPPER .writerWithType(HttpLoadQueuePeon.RESPONSE_ENTITY_TYPE_REF) .writeValueAsBytes(statuses)
Futures.immediateFuture( new ByteArrayInputStream( jsonMapper.writerWithType(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, Futures.immediateFuture( new ByteArrayInputStream( jsonMapper.writerWithType(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, Futures.immediateFuture( new ByteArrayInputStream( jsonMapper.writerWithType(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( true, Futures.immediateFuture( new ByteArrayInputStream( jsonMapper.writerWithType(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false, Futures.immediateFuture( new ByteArrayInputStream( jsonMapper.writerWithType(typeRef).writeValueAsBytes( new ChangeRequestsSnapshot( false,
public Void execute(CommandContext commandContext) { if (processDefinitionId == null) { throw new ActivitiIllegalArgumentException("process definition id is null"); } if (infoNode == null) { throw new ActivitiIllegalArgumentException("process definition info node is null"); } ProcessDefinitionInfoEntityManager definitionInfoEntityManager = commandContext.getProcessDefinitionInfoEntityManager(); ProcessDefinitionInfoEntity definitionInfoEntity = definitionInfoEntityManager.findProcessDefinitionInfoByProcessDefinitionId(processDefinitionId); if (definitionInfoEntity == null) { definitionInfoEntity = definitionInfoEntityManager.create(); definitionInfoEntity.setProcessDefinitionId(processDefinitionId); commandContext.getProcessDefinitionInfoEntityManager().insertProcessDefinitionInfo(definitionInfoEntity); } if (infoNode != null) { try { ObjectWriter writer = commandContext.getProcessEngineConfiguration().getObjectMapper().writer(); commandContext.getProcessDefinitionInfoEntityManager().updateInfoJson(definitionInfoEntity.getId(), writer.writeValueAsBytes(infoNode)); } catch (Exception e) { throw new ActivitiException("Unable to serialize info node " + infoNode); } } return null; }