Package com.fasterxml.jackson.databind

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


                {
                  @Override
                  public void write(OutputStream outputStream) throws IOException, WebApplicationException
                  {
                    // json serializer will always close the yielder
                    jsonWriter.writeValue(outputStream, yielder);
                    outputStream.close();
                  }
                },
                isSmile ? APPLICATION_JSON : APPLICATION_SMILE
            )
View Full Code Here


    resp.setContentType("application/json");
    ObjectMapper om = new ObjectMapper();
    try
    {
      ObjectWriter writer = om.writer().withType(om.constructType(getClass().getMethod("prototype").getGenericReturnType()));
      writer.writeValue(resp.getOutputStream(), Lists.newArrayList(one, two, three));
    }
    catch (Exception e)
    {
      throw new ServletException(e);
    }
View Full Code Here

        JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
        ObjectWriter writer = getWriterForView(view.getView());
        JsonGenerator jsonGenerator =
                writer.getFactory().createGenerator(outputMessage.getBody(), encoding);
        try {
            writer.writeValue(jsonGenerator, view.getData());
        }
        catch (IOException ex) {
            throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
        }
    }
View Full Code Here

         // but we may need to force root type:
         if (rootType != null) {
            writer = writer.withType(rootType);
         }
         value = endpoint.modifyBeforeWrite(value);
         writer.writeValue(jg, value);
      } finally {
         jg.close();
      }
   }
View Full Code Here

        ObjectWriter writer = mapper.writer();

        Writer output = new StringWriter();

        try {
            writer.writeValue(output, object);
        } catch (IOException e) {
            log.error("Unable to serialize object to json", e);
        }

        return output.toString();
View Full Code Here

    @Override
    public void onCompleteResponse(HttpRequest request, HttpResponse httpResponse) {
        try {
            ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
            Session targetSession = Session.newSession(request, httpResponse);
            writer.writeValue(this.file, prepareTargetSessions(targetSession));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        System.out.println(schema.getColumnDesc());
        ObjectWriter writer = mapper.writer(schema);
        // supplying the file directly does not work.
        // java.lang.UnsupportedOperationException: Generator of type com.fasterxml.jackson.core.json.UTF8JsonGenerator
        // does not support schema of type 'CSV'
        writer.writeValue(new FileOutputStream(path), models);
    }
}
View Full Code Here

        }
        else {
            writer = objectMapper.writer();
        }

        writer.writeValue(jsonGenerator, value);

        // add a newline so when you use curl it looks nice
        outputStream.write('\n');
    }
View Full Code Here

        }
        else {
            writer = objectMapper.writer();
        }

        writer.writeValue(jsonGenerator, value);

        // add a newline so when you use curl it looks nice
        outputStream.write('\n');
    }
View Full Code Here

      try {
        ObjectMapper objectMapper = new ObjectMapper();
       
        ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
       
        writer.writeValue(outputFile, result.getEnvironments());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
     
      return null;
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.