Example usage for com.fasterxml.jackson.databind.node JsonNodeFactory instance

List of usage examples for com.fasterxml.jackson.databind.node JsonNodeFactory instance

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node JsonNodeFactory instance.

Prototype

JsonNodeFactory instance

To view the source code for com.fasterxml.jackson.databind.node JsonNodeFactory instance.

Click Source Link

Usage

From source file:com.ikanow.aleph2.v1.document_db.utils.JsonNodeBsonUtils.java

/** Creates a lazy object node from a MapWritable 
 * @param m/*from   w  ww. j  a  va  2 s  .c  o m*/
 * @return
 */
public static ObjectNode from(final BSONObject b) {
    return new ObjectNodeWrapper(JsonNodeFactory.instance, b);
}

From source file:net.hamnaberg.json.Property.java

static ArrayNode toArrayNode(Iterable<Property> data) {
    return stream(data.spliterator(), false).map(Extended::asJson).collect(JsonNodeFactory.instance::arrayNode,
            ArrayNode::add, ArrayNode::addAll);
}

From source file:com.chenchengzhi.windtalkers.server.TalkerLeader.java

@Override
public Message reply(Message request) {
    ObjectNode responseNode = new ObjectNode(JsonNodeFactory.instance);
    ArrayNode talkers = new ArrayNode(JsonNodeFactory.instance);
    for (WindTalkerID id : WindTalkerID.values()) {
        talkers.add(id.getName());//from  w ww . ja  va 2s .  co  m
    }
    responseNode.put("Windtalkers", talkers);
    request.setResponseBody(responseNode);
    return request;
}

From source file:net.hamnaberg.json.Item.java

public static Item create(Optional<URI> href, Iterable<Property> properties, List<Link> links) {
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    href.ifPresent(uri -> node.put("href", uri.toString()));
    if (!Iterables.isEmpty(properties)) {
        node.set("data", StreamSupport.stream(properties.spliterator(), false).map(Extended::asJson)
                .collect(JsonNodeFactory.instance::arrayNode, ArrayNode::add, ArrayNode::addAll));
    }// w w  w.j  ava2 s.co m
    if (!Iterables.isEmpty(links)) {
        node.set("links", StreamSupport.stream(links.spliterator(), false).map(Extended::asJson)
                .collect(JsonNodeFactory.instance::arrayNode, ArrayNode::add, ArrayNode::addAll));
    }
    return new Item(node);
}

From source file:net.hamnaberg.json.Query.java

public static Query create(Target target, String rel, Optional<String> prompt, Optional<String> name,
        Iterable<Property> data) {
    ObjectNode obj = JsonNodeFactory.instance.objectNode();
    obj.put("href", target.toString());
    if (target.isURITemplate()) {
        obj.put("encoding", "uri-template");
    }/*from  ww  w .j  a  v  a2  s .c o m*/
    obj.put("rel", rel);
    prompt.ifPresent(value -> obj.put("prompt", value));
    name.ifPresent(value -> obj.put("name", value));
    if (!Iterables.isEmpty(data)) {
        obj.set("data", StreamSupport.stream(data.spliterator(), false).map(Extended::asJson)
                .collect(JsonNodeFactory.instance::arrayNode, ArrayNode::add, ArrayNode::addAll));
    }
    return new Query(obj);
}

From source file:io.fabric8.collector.elasticsearch.JsonNodes.java

/**
 * Creates nested objects if they don't exist on the given paths.
 *
 * @returns the last object or null if it could not be created
 *///  w w  w. j a v a  2s . co  m
public static ObjectNode setObjects(JsonNode node, String... paths) {
    JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
    JsonNode iter = node;
    for (String path : paths) {
        if (!iter.isObject()) {
            return null;
        }
        ObjectNode object = (ObjectNode) iter;
        iter = object.get(path);
        if (iter == null || !iter.isObject()) {
            iter = nodeFactory.objectNode();
            object.set(path, iter);
        }
    }
    return (ObjectNode) iter;
}

From source file:net.hamnaberg.json.Error.java

public static Error create(Optional<String> title, Optional<String> code, Optional<String> message) {
    final ObjectNode obj = JsonNodeFactory.instance.objectNode();
    title.ifPresent(value -> obj.put("title", value));
    code.ifPresent(value -> obj.put("code", value));
    message.ifPresent(value -> obj.put("message", value));
    return new Error(obj);
}

From source file:io.liveoak.keycloak.AuthInterceptorTest.java

@BeforeClass
public static void loadExtensions() throws Exception {
    loadExtension("auth", new KeycloakExtension(), createTestConfig());
    loadExtension("auth-test", new MockExtension(MockRootResource.class));
    setupAuthInterceptor();// w  w  w  .jav a 2s .co  m
    installTestAppResource("auth", "auth", JsonNodeFactory.instance.objectNode());
    installTestAppResource("auth-test", "auth-test", JsonNodeFactory.instance.objectNode());
}

From source file:org.apache.usergrid.android.sdk.utils.JsonUtils.java

public static void setStringProperty(Map<String, JsonNode> properties, String name, String value) {
    if (value == null) {
        properties.remove(name);// www .ja  v a  2 s  .co m
    } else {
        properties.put(name, JsonNodeFactory.instance.textNode(value));
    }
}

From source file:net.hamnaberg.json.Link.java

public static Link create(URI href, String rel, Optional<String> prompt, Optional<String> name,
        Optional<Render> render) {
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    node.put("href", Optional.ofNullable(href)
            .orElseThrow(() -> new IllegalArgumentException("Href may not be null")).toString());
    node.put("rel", Optional.ofNullable(rel)
            .orElseThrow(() -> new IllegalArgumentException("Relation may not be null")));
    prompt.ifPresent(value -> node.put("prompt", value));
    render.ifPresent(value -> node.put("render", value.getName()));
    name.ifPresent(value -> node.put("name", value));
    return new Link(node);
}