use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project ignite by apache.
the class DecisionTreeModel method toJSON.
/**
* {@inheritDoc}
*/
@Override
public void toJSON(Path path) {
ObjectMapper mapper = new ObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.addMixIn(DecisionTreeModel.class, JSONModelMixIn.class);
ObjectWriter writer = mapper.writerFor(DecisionTreeModel.class).withAttribute("formatVersion", JSONModel.JSON_MODEL_FORMAT_VERSION).withAttribute("timestamp", System.currentTimeMillis()).withAttribute("uid", "dt_" + UUID.randomUUID().toString()).withAttribute("modelClass", DecisionTreeModel.class.getSimpleName());
try {
File file = new File(path.toAbsolutePath().toString());
writer.writeValue(file, this);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project ignite by apache.
the class GDBModel method toJSON.
/**
* {@inheritDoc}
*/
@Override
public void toJSON(Path path) {
ObjectMapper mapper = new ObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.addMixIn(GDBModel.class, JSONModelMixIn.class);
ObjectWriter writer = mapper.writerFor(GDBModel.class).withAttribute("formatVersion", JSONModel.JSON_MODEL_FORMAT_VERSION).withAttribute("timestamp", System.currentTimeMillis()).withAttribute("uid", "dt_" + UUID.randomUUID().toString()).withAttribute("modelClass", GDBModel.class.getSimpleName());
try {
File file = new File(path.toAbsolutePath().toString());
writer.writeValue(file, this);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project CzechIdMng by bcvsolutions.
the class LoginControllerRestTest method serialize.
private String serialize(Map<String, String> login) throws IOException {
StringWriter sw = new StringWriter();
ObjectWriter writer = getMapper().writerFor(HashMap.class);
writer.writeValue(sw, login);
//
return sw.toString();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project navajo by Dexels.
the class BaseRuntimeImpl method writeNode.
@Override
public void writeNode(JsonNode node) throws IOException {
setMimeType("application/json; charset=utf-8");
ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter();
writer.writeValue(getOutputWriter(), node);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter in project navajo by Dexels.
the class ServletArticleRuntimeImpl method commit.
@Override
public void commit() throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode;
try {
rootNode = mapper.readValue(writer.toString(), JsonNode.class);
} catch (JsonParseException e) {
logger.error("JSON parse error: ", e);
response.getWriter().write("Invalid JSON follows:\n");
response.getWriter().write(writer.toString());
return;
}
ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter();
writer.writeValue(response.getWriter(), rootNode);
}
Aggregations