Example usage for com.fasterxml.jackson.databind JsonNode textValue

List of usage examples for com.fasterxml.jackson.databind JsonNode textValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonNode textValue.

Prototype

public String textValue() 

Source Link

Usage

From source file:com.github.tomakehurst.wiremock.http.HttpHeadersJsonDeserializer.java

private static Function<JsonNode, String> toStringValues() {
    return new Function<JsonNode, String>() {
        public String apply(JsonNode node) {
            return node.textValue();
        }/*from w w w.ja  v a 2  s .  co m*/
    };
}

From source file:com.siemens.sw360.datahandler.common.JacksonUtils.java

public static boolean arrayContains(ArrayNode array, String needle) {
    for (JsonNode jsonNode : array) {
        if (jsonNode.isTextual() && needle.equals(jsonNode.textValue())) {
            return true;
        }/*ww  w.  j  av a2 s . co m*/
    }
    return false;
}

From source file:com.siemens.sw360.datahandler.common.JacksonUtils.java

public static int arrayPosition(ArrayNode array, String needle) {
    for (int i = 0; i < array.size(); i++) {
        JsonNode jsonNode = array.get(i);
        if (jsonNode.isTextual() && needle.equals(jsonNode.textValue())) {
            return i;
        }//from   w w w . j a va2s .c  o  m
    }
    return -1;
}

From source file:com.github.fge.jsonschema.TestUtils.java

public static String buildMessage(final MessageBundle BUNDLE, final String key, final JsonNode params,
        final JsonNode data) {
    final ProcessingMessage message = new ProcessingMessage().setMessage(BUNDLE.getMessage(key));
    if (params != null) {
        String name;//from   w  w  w. j a va2  s.  c  o  m
        JsonNode value;
        for (final JsonNode node : params) {
            name = node.textValue();
            value = data.get(name);
            message.putArgument(name, valueToArgument(value));
        }
    }
    return message.getMessage();
}

From source file:com.siemens.sw360.datahandler.common.JacksonUtils.java

public static Set<String> extractSet(ArrayNode array) throws SW360Exception {
    Set<String> result = new HashSet<>();

    for (JsonNode jsonNode : array) {
        if (jsonNode.isTextual())
            result.add(jsonNode.textValue());
        else//  ww w  .ja va2  s . c  o m
            throw new SW360Exception("Non textual string ?!");
    }
    return result;
}

From source file:com.github.fge.uritemplate.Util.java

public static VariableValue fromJson(final JsonNode node) {
    if (node.isTextual())
        return new ScalarValue(node.textValue());
    if (node.isArray()) {
        final ListValue.Builder builder = ListValue.newBuilder();
        for (final JsonNode element : node)
            builder.add(element.textValue());
        return builder.build();
    }//from   w w  w .j  a  va  2 s.c o m
    if (node.isObject()) {
        final MapValue.Builder builder = MapValue.newBuilder();
        final Iterator<Map.Entry<String, JsonNode>> iterator = node.fields();
        Map.Entry<String, JsonNode> entry;
        while (iterator.hasNext()) {
            entry = iterator.next();
            builder.put(entry.getKey(), entry.getValue().textValue());
        }
        return builder.build();
    }
    throw new RuntimeException("cannot bind JSON to variable value");
}

From source file:com.github.fge.jsonschema.keyword.digest.draftv4.DraftV4DependenciesDigester.java

private static JsonNode sortedSet(final JsonNode node) {
    final List<JsonNode> list = Lists.newArrayList(node);

    Collections.sort(list, new Comparator<JsonNode>() {
        @Override//w  w  w. j av  a 2s.  c o  m
        public int compare(final JsonNode o1, final JsonNode o2) {
            return o1.textValue().compareTo(o2.textValue());
        }
    });

    final ArrayNode ret = FACTORY.arrayNode();
    ret.addAll(list);
    return ret;
}

From source file:com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3DependenciesDigester.java

private static JsonNode sortedSet(final JsonNode node) {
    final SortedSet<JsonNode> set = Sets.newTreeSet(new Comparator<JsonNode>() {
        @Override/*w w w.  ja  v  a2 s  . c o m*/
        public int compare(final JsonNode o1, final JsonNode o2) {
            return o1.textValue().compareTo(o2.textValue());
        }
    });

    set.addAll(Sets.newHashSet(node));
    final ArrayNode ret = FACTORY.arrayNode();
    ret.addAll(set);
    return ret;
}

From source file:com.syncedsynapse.kore2.utils.JsonUtils.java

public static List<String> stringListFromJsonNode(JsonNode node, String key) {
    if (node == null)
        return new ArrayList<String>(0);
    JsonNode value = node.get(key);// w  w w . java 2  s . c  o  m
    if (value == null)
        return new ArrayList<String>(0);

    ArrayNode arrayNode = (ArrayNode) value;
    ArrayList<String> result = new ArrayList<String>(arrayNode.size());
    for (JsonNode innerNode : arrayNode) {
        result.add(innerNode.textValue());
    }
    return result;
}

From source file:org.xbmc.kore.utils.JsonUtils.java

public static List<String> stringListFromJsonNode(JsonNode node, String key) {
    if (node == null)
        return new ArrayList<String>(0);
    JsonNode value = node.get(key);// w w w.jav a2 s .com
    if (value == null)
        return new ArrayList<String>(0);

    ArrayList<String> result;
    if (value.isArray()) {
        ArrayNode arrayNode = (ArrayNode) value;
        result = new ArrayList<String>(arrayNode.size());
        for (JsonNode innerNode : arrayNode) {
            result.add(innerNode.textValue());
        }
    } else {
        // This isn't exactly what we're expecting, but we can return the text value
        result = new ArrayList<String>(1);
        result.add(value.textValue());
    }
    return result;
}