use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project jackson-databind by FasterXML.
the class ObjectReaderTest method testNodeHandling.
public void testNodeHandling() throws Exception {
JsonNodeFactory nodes = new JsonNodeFactory(true);
ObjectReader r = MAPPER.reader().with(nodes);
// but also no further changes if attempting again
assertSame(r, r.with(nodes));
assertTrue(r.createArrayNode().isArray());
assertTrue(r.createObjectNode().isObject());
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project jackson-databind by FasterXML.
the class ArrayNodeTest method testDirectCreation2.
public void testDirectCreation2() throws IOException {
JsonNodeFactory f = objectMapper().getNodeFactory();
ArrayList<JsonNode> list = new ArrayList<>();
list.add(f.booleanNode(true));
list.add(f.textNode("foo"));
ArrayNode n = new ArrayNode(f, list);
assertEquals(2, n.size());
assertTrue(n.get(0).isBoolean());
assertTrue(n.get(1).isTextual());
// also, should fail with invalid set attempt
try {
n.set(2, f.nullNode());
fail("Should not pass");
} catch (IndexOutOfBoundsException e) {
verifyException(e, "illegal index");
}
n.insert(1, (String) null);
assertEquals(3, n.size());
assertTrue(n.get(0).isBoolean());
assertTrue(n.get(1).isNull());
assertTrue(n.get(2).isTextual());
n.removeAll();
n.insert(0, (JsonNode) null);
assertEquals(1, n.size());
assertTrue(n.get(0).isNull());
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project swagger-parser by swagger-api.
the class ResolverCacheTest method constructJsonTree.
private Pair<JsonNode, JsonNode> constructJsonTree(String... properties) {
JsonNodeFactory factory = new JsonNodeFactory(true);
final ObjectNode parent = factory.objectNode();
ObjectNode current = parent;
for (String property : properties) {
current = current.putObject(property);
}
current.put("key", "value");
return Pair.of((JsonNode) parent, (JsonNode) current);
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project graphhopper by graphhopper.
the class InfoServlet method doGet.
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
BBox bb = storage.getBounds();
List<Double> list = new ArrayList<>(4);
list.add(bb.minLon);
list.add(bb.minLat);
list.add(bb.maxLon);
list.add(bb.maxLat);
final JsonNodeFactory jsonNodeFactory = new JsonNodeFactory(false);
final ObjectNode json = jsonNodeFactory.objectNode();
json.putPOJO("bbox", list);
String[] vehicles = storage.getEncodingManager().toString().split(",");
json.putPOJO("supported_vehicles", vehicles);
ObjectNode features = json.putObject("features");
for (String v : vehicles) {
ObjectNode perVehicleJson = features.putObject(v);
perVehicleJson.put("elevation", hasElevation);
}
json.put("version", Constants.VERSION);
json.put("build_date", Constants.BUILD_DATE);
StorableProperties props = storage.getProperties();
json.put("import_date", props.get("datareader.import.date"));
if (!Helper.isEmpty(props.get("datareader.data.date")))
json.put("data_date", props.get("datareader.data.date"));
String tmpDate = props.get(Parameters.CH.PREPARE + "date");
if (!Helper.isEmpty(tmpDate)) {
json.put("prepare_ch_date", tmpDate);
json.put("prepare_date", tmpDate);
}
writeJson(req, res, json);
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project fabric8-maven-plugin by fabric8io.
the class HelmMojo method createTemplateParameters.
private void createTemplateParameters(File outputDir, Template template, File templatesDir) throws MojoExecutionException {
JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
ObjectNode values = nodeFactory.objectNode();
List<io.fabric8.openshift.api.model.Parameter> parameters = template.getParameters();
if (parameters == null || parameters.isEmpty()) {
return;
}
List<HelmParameter> helmParameters = new ArrayList<>();
for (io.fabric8.openshift.api.model.Parameter parameter : parameters) {
HelmParameter helmParameter = new HelmParameter(parameter);
helmParameter.addToValue(values);
helmParameters.add(helmParameter);
}
File outputChartFile = new File(outputDir, "values.yaml");
try {
saveYaml(values, outputChartFile);
} catch (IOException e) {
throw new MojoExecutionException("Failed to save chart values " + outputChartFile + ": " + e, e);
}
// now lets replace all the parameter expressions in each template
File[] files = templatesDir.listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
String extension = Files.getExtension(file.getName()).toLowerCase();
if (extension.equals("yaml") || extension.equals("yml")) {
convertTemplateParameterExpressionsWithHelmExpressions(file, helmParameters);
}
}
}
}
}
Aggregations