Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonNode.textValue()


     */
    protected static Object getValue(JsonNode node, String key) {
        JsonNode jsonNode = node.get(key);
        if (jsonNode != null) {
            if (jsonNode.isTextual()) {
                return jsonNode.textValue();
            } else if (jsonNode.isLong()) {
                return jsonNode.asLong();
            }
        }
        return null;
View Full Code Here


                try {
                    // sometimes we erroneously get strings that would parse into valid numbers and maybe other edge
                    // cases (eg. when using system property overrides in typesafe-config). So we'll go ahead and guard
                    // with this regex to make sure we only get reasonable candidates.
                    Time time = prop.getAnnotation(Time.class);
                    if ((time != null) && NUMBER_UNIT.matcher(fieldValue.textValue()).matches()) {
                        Duration dropWizardDuration = Duration.parse(fieldValue.asText());
                        long asLong = time.value().convert(dropWizardDuration.getQuantity(), dropWizardDuration.getUnit());
                        fieldValues.put(propertyName, asLong);
                    } else if ((prop.getAnnotation(Bytes.class) != null) &&
                               NUMBER_UNIT.matcher(fieldValue.textValue()).matches()) {
View Full Code Here

                    if ((time != null) && NUMBER_UNIT.matcher(fieldValue.textValue()).matches()) {
                        Duration dropWizardDuration = Duration.parse(fieldValue.asText());
                        long asLong = time.value().convert(dropWizardDuration.getQuantity(), dropWizardDuration.getUnit());
                        fieldValues.put(propertyName, asLong);
                    } else if ((prop.getAnnotation(Bytes.class) != null) &&
                               NUMBER_UNIT.matcher(fieldValue.textValue()).matches()) {
                        Size dropWizardSize = Size.parse(fieldValue.asText());
                        long asLong = dropWizardSize.toBytes();
                        fieldValues.put(propertyName, asLong);
                    }
                } catch (Throwable cause) {
View Full Code Here

                    }
                    else if (value.isLong()) {
                        call.setLong(field, value.asLong());
                    }
                    else {
                        call.setString(field, value.textValue());
                    }
                }
            }
            else {
                throw new InvalidArgumentTypeException("JSON must be object or array");
View Full Code Here

        final ObjectMapper mapper = new ObjectMapper();
        final JsonNode actualObj = mapper.readTree(jsonString);

        // When
        final JsonNode jsonNode1 = actualObj.get("k1");
        assertThat(jsonNode1.textValue(), equalTo("v1"));
    }

    // custom deserialization

    @Test
View Full Code Here

        return acHost;
    }

    private static String getAttributeAsText(JsonNode json, String name) {
        JsonNode jsonNode = json.get(name);
        return jsonNode == null ? null : jsonNode.textValue();
    }

}
View Full Code Here

            {
                JsonNode node = i.next();
                if (node.has("status"))
                    if (!pendingParametersOnly
                        || node.get("status").textValue().equals(Configuration.ParameterStatus.Pending.toString()))
                        parameters.add(node.textValue());
            }

            // Finally return the list of (all or pending) parameters.
            return parameters;
        }
View Full Code Here

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode node = objectMapper.readTree(FileUtils.readFileToByteArray(new File(swaggerOutputDir, "service.json")));

        JsonNode basePathNode = node.get("basePath");
        Assert.assertEquals(basePathNode.textValue(), "http://www.example.com/restapi/doc");

        JsonNode apis = node.get("apis");
        Assert.assertEquals(apis.size(), 3);
        List<String> pathInService = new ArrayList<String>();
        for (JsonNode api : apis) {
View Full Code Here

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode node = objectMapper.readTree(FileUtils.readFileToByteArray(new File(swaggerOutputDir, "service.json")));

        JsonNode basePathNode = node.get("basePath");
        Assert.assertEquals(basePathNode.textValue(), "http://www.example.com/restapi/doc");

        JsonNode apis = node.get("apis");
        Assert.assertEquals(apis.size(), 3);
        List<String> pathInService = new ArrayList<String>();
        for (JsonNode api : apis) {
View Full Code Here

        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode node = objectMapper.readTree(FileUtils.readFileToByteArray(new File(swaggerOutputDir, "service.json")));

        JsonNode basePathNode = node.get("basePath");
        Assert.assertEquals(basePathNode.textValue(), "http://example.com");

        JsonNode apis = node.get("apis");
        Assert.assertEquals(apis.size(), 3);
        List<String> pathInService = new ArrayList<String>();
        for (JsonNode api : apis) {
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.