Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper.writeValue()


            if (ck.getPorts() != null && !ck.getPorts().isEmpty()) {
                m.put("ports", ck.getPorts().toArray(new Integer[0]));
            }
            list.add(m);
        }
        om.writeValue(out, list);
    }

    public void read(InputStream in) throws IOException {
        ObjectMapper om = new ObjectMapper();
        List<Map<String, Object>> l = om.readValue(in, List.class);
View Full Code Here


   * @throws IOException Signals that an I/O exception has occurred.
   */
  private void writeObject(final java.io.ObjectOutputStream out) throws IOException {
    final ObjectMapper mapper = new ObjectMapper();
    mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
    mapper.writeValue(out, req);
  }
 
  /**
   * Read object.
   *
 
View Full Code Here

     */
    public void writeTo(Writer writer) throws IOException {
        ObjectMapper factory = new ObjectMapper();
        ObjectNode template = JsonNodeFactory.instance.objectNode();
        template.set("template", asJson());
        factory.writeValue(writer, template);
    }

    @Override
    public String toString() {
        StringWriter writer = new StringWriter();
View Full Code Here

   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
   
    ObjectMapper om = new ObjectMapper(new BsonFactory());
    om.registerModule(new BsonModule());
    om.writeValue(baos, m);

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
View Full Code Here

        bsonFactory.enable(fe);
      }
    }
    ObjectMapper om = new ObjectMapper(bsonFactory);
    om.registerModule(new BsonModule());
    om.writeValue(baos, data);

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
View Full Code Here

   
    //with BSON we don't have to convert to base64
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BsonFactory bsonFactory = new BsonFactory();
    ObjectMapper om = new ObjectMapper(bsonFactory);
    om.writeValue(baos, data);
   
    //document header (4 bytes) + type (1 byte) + field_name ("binary", 6 bytes) +
    //end_of_string (1 byte) + binary_size (4 bytes) + subtype (1 byte) +
    //binary_data (13 bytes) + end_of_document (1 byte)
    int expectedLen = 4 + 1 + 6 + 1 + 4 + 1 + 13 + 1;
View Full Code Here

    public void writeTo(Writer writer) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode obj = mapper.createObjectNode();
        obj.set("collection", asJson());
        mapper.writeValue(writer, obj);
    }

    @Override
    public String toString() {
        StringWriter writer = new StringWriter();
View Full Code Here

            if (!entryNotes.getOperations().isEmpty()) {
                Path doc = apidocsTarget.resolve(classDoc.qualifiedName() + ".notes.json");
                rootDoc.printNotice("generating RESTX API entry notes for " + classDoc.qualifiedName() + " ...");
                trace.trace("generating notes in " + doc.toAbsolutePath());
                try {
                    mapper.writeValue(doc.toFile(), entryNotes);
                } catch (IOException e) {
                    trace.trace("can't write to api doc file " + doc.toFile() + ": " + e);
                    rootDoc.printError("can't write to api doc file " + doc.toFile() + ": " + e);
                }
            } else {
View Full Code Here

            throws GenieException, ClientException, IOException {
        Mockito.when(this.response.isSuccess()).thenReturn(true);

        final ObjectMapper mapper = new ObjectMapper();
        final StringWriter writer = new StringWriter();
        mapper.writeValue(writer, APPLICATION);
        final String inputEntity = writer.toString();
        final InputStream is = new ByteArrayInputStream(inputEntity.getBytes(Charset.forName("UTF-8")));
        Mockito.when(this.response.getInputStream()).thenReturn(is);

        Mockito.when(this.restClient.executeWithLoadBalancer(this.request)).thenReturn(this.response);
View Full Code Here

            );
        }

        final ObjectMapper mapper = new ObjectMapper();
        final StringWriter writer = new StringWriter();
        mapper.writeValue(writer, commands);
        final String inputEntity = writer.toString();
        final InputStream is = new ByteArrayInputStream(inputEntity.getBytes(Charset.forName("UTF-8")));
        Mockito.when(this.response.getInputStream()).thenReturn(is);
        Mockito.when(this.restClient.executeWithLoadBalancer(this.request)).thenReturn(this.response);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.