Package com.fasterxml.jackson.databind

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


            ObjectMapper mapper = new ObjectMapper();
            PizzaOrder order = mapper.readValue(req.getInputStream(), PizzaOrder.class);

            StringWriter sw = new StringWriter();
            mapper.writeValue(sw, order);
            System.out.println("Request: " + sw.toString());

            OrderConfirmation confirmation = new OrderConfirmation();
            confirmation.order_id = 123123;
            confirmation.order = order;
View Full Code Here


            confirmation.ready_time = System.currentTimeMillis() + 1000 * 60 * 30; // in
                                                                                   // 30
                                                                                   // min.

            sw = new StringWriter();
            mapper.writeValue(sw, confirmation);
            System.out.println("Response: " + sw.toString());

            resp.setContentType(Resource.CONTENT_TYPE_JSON);
            mapper.writeValue(resp.getOutputStream(), confirmation);
            System.out.println("Pizza Order Confirimed: " + confirmation.order_id);
View Full Code Here

            sw = new StringWriter();
            mapper.writeValue(sw, confirmation);
            System.out.println("Response: " + sw.toString());

            resp.setContentType(Resource.CONTENT_TYPE_JSON);
            mapper.writeValue(resp.getOutputStream(), confirmation);
            System.out.println("Pizza Order Confirimed: " + confirmation.order_id);

        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
View Full Code Here

            toppings.add(new Topping("pineapple", 0.50));
            toppings.add(new Topping("ham", 0.50));
            toppings.add(new Topping("peperoni", 0.50));

            StringWriter sw = new StringWriter();
            mapper.writeValue(sw, toppings);
            System.out.println("Response: " + sw.toString());

            resp.setContentType(Resource.CONTENT_TYPE_JSON);
            mapper.writeValue(resp.getOutputStream(), toppings);
View Full Code Here

            StringWriter sw = new StringWriter();
            mapper.writeValue(sw, toppings);
            System.out.println("Response: " + sw.toString());

            resp.setContentType(Resource.CONTENT_TYPE_JSON);
            mapper.writeValue(resp.getOutputStream(), toppings);

        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            System.out.flush();
View Full Code Here

        Map<String,Object> result = new HashMap<String, Object>();
        result.put("type",ex.getClass().getSimpleName());
        result.put("message",ex.getMessage());

        ObjectMapper mapper = new ObjectMapper();
        mapper.writeValue(out,result);

    }

    /**
     * Get the resource's path
View Full Code Here

  }

  private void writeObject(java.io.ObjectOutputStream out) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
    mapper.writeValue(out, req);
  }

  private void readObject(java.io.ObjectInputStream in) throws IOException,
      ClassNotFoundException {
    ObjectMapper mapper = new ObjectMapper();
View Full Code Here

    @Override
    public String marshal(Object payload) {
        ObjectMapper mapper = new ObjectMapper();
        StringWriter writer = new StringWriter();
        try {
            mapper.writeValue(writer, payload);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return writer.toString();
    }
View Full Code Here

        HttpURLConnection connection = openConnection("contacts/%s/subscriptions/", phoneNr);
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        ObjectMapper mapper = new ObjectMapper();
        OutputStream out = connection.getOutputStream();
        mapper.writeValue(out, new Subscription(subscriptionName));
        out.close();
        connection.connect();
        int statusCode = connection.getResponseCode();
        if (statusCode == 200) {
            // Already subscribed
View Full Code Here

        HttpURLConnection connection = openConnection("messages/in/%d/reply/", messageId);
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        ObjectMapper mapper = new ObjectMapper();
        OutputStream out = connection.getOutputStream();
        mapper.writeValue(out, new Reply(content));
        out.close();
        connection.connect();
        int statusCode = connection.getResponseCode();
        if (statusCode == 404) {
            // Original message not found
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.