use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project hippo by NHS-digital-website.
the class OdsUtils method main.
public static void main(String[] args) throws IOException {
OdsUtils util = new OdsUtils();
int offSet = 1;
List<Organisation> finalList = new ArrayList();
while (true) {
String str = util.extracted(String.valueOf(offSet)).toString().trim();
System.out.println("Value is " + str.length());
List<Organisation> tempList = util.jsonFomart(str);
System.out.println("Value is tempList " + tempList.size());
if (tempList != null && tempList.size() > 0) {
finalList.addAll(tempList);
offSet += 1000;
System.out.println("Value of offSet is " + offSet);
System.out.println("Size of finalList is " + finalList.size());
} else {
break;
}
}
ObjectMapper objectMapper = new ObjectMapper();
// Set pretty printing of json
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
ObjectWriter writer = objectMapper.writer(new DefaultPrettyPrinter());
writer.writeValue(new File("ODS_JSON.json"), finalList);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project cxf by apache.
the class Java2SwaggerMojo method generateSwaggerPayLoad.
private void generateSwaggerPayLoad() throws MojoExecutionException {
if (outputFile == null && project != null) {
// Put the json in target/generated/json
// put the yaml in target/generated/yaml
final String name;
if (outputFileName != null) {
name = outputFileName;
} else if (resourceClasses.size() == 1) {
name = resourceClasses.iterator().next().getSimpleName();
} else {
name = "swagger";
}
outputFile = (project.getBuild().getDirectory() + "/generated/" + payload.toLowerCase() + "/" + name + "." + payload.toLowerCase()).replace("/", File.separator);
}
FileUtils.mkDir(new File(outputFile).getParentFile());
try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
if ("json".equals(this.payload)) {
ObjectWriter jsonWriter = mapper.writer(new DefaultPrettyPrinter());
writer.write(jsonWriter.writeValueAsString(swagger));
} else if ("yaml".equals(this.payload)) {
writer.write(Yaml.pretty().writeValueAsString(swagger));
}
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
// with the enclosing project
if (attachSwagger && outputFile != null) {
File jsonFile = new File(outputFile);
if (jsonFile.exists()) {
if (classifier != null) {
projectHelper.attachArtifact(project, payload.toLowerCase(), classifier, jsonFile);
} else {
projectHelper.attachArtifact(project, payload.toLowerCase(), jsonFile);
}
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project CzechIdMng by bcvsolutions.
the class DefaultRecaptchaRestTest method jsonify.
private String jsonify(RecaptchaRequest dto) throws IOException {
ObjectMapper m = new ObjectMapper();
StringWriter sw = new StringWriter();
ObjectWriter writer = m.writerFor(RecaptchaRequest.class);
writer.writeValue(sw, dto);
return sw.toString();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project snow-owl by b2ihealthcare.
the class CsvMessageConverter method writeInternal.
@Override
protected void writeInternal(Collection<Object> items, HttpOutputMessage output) throws IOException, HttpMessageNotWritableException {
if (!items.isEmpty()) {
output.getHeaders().setContentType(MEDIA_TYPE);
output.getHeaders().set(CONTENT_DISPOSITION, ATTACHMENT);
try (OutputStream out = output.getBody()) {
final CsvMapper mapper = new CsvMapper();
mapper.readerFor(Collection.class);
// XXX The mapper is auto closing the writer after the first write out for some reason
mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
final CsvSchema schema = mapper.schemaFor(items.iterator().next().getClass()).withHeader().withColumnSeparator('\t');
final ObjectWriter writer = mapper.writer(schema);
writer.writeValues(out).writeAll(items);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project CzechIdMng by bcvsolutions.
the class NotificationRestTest method jsonify.
String jsonify(IdmNotificationDto dto) throws IOException {
ObjectMapper m = new ObjectMapper();
StringWriter sw = new StringWriter();
ObjectWriter writer = m.writerFor(IdmNotificationDto.class);
writer.writeValue(sw, dto);
return sw.toString();
}
Aggregations