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:easyrpc.client.serialization.jsonrpc.JSONCaller.java

@Override
public byte[] serializeCall(Object theProxy, Method thisMethod, Object[] args) throws Throwable {
    ObjectNode sc = JsonNodeFactory.instance.objectNode();
    sc.put("jsonrpc", "2.0");
    sc.put("method", thisMethod.getName());

    if (args != null && args.length > 0) {
        ArrayNode params = JsonNodeFactory.instance.arrayNode();
        for (Object arg : args) {
            addType(arg, params);//w w  w . j  a  v a  2  s. c o m
        }
        sc.set("params", params);
    }
    sc.put("id", UUID.randomUUID().toString());

    String json = sc.toString();
    return json.getBytes();
}

From source file:actors.DeployLogRelay.java

@Override
public void onReceive(final Object message) throws Exception {
    if ("check".equals(message)) {
        final List<DeploymentLog> logs = DeploymentLog.getLogsSince(_deployment, DeploymentLog.ref(_lastId));

        final ObjectNode node = JsonNodeFactory.instance.objectNode();
        final ArrayNode messages = node.putArray("messages");
        logs.forEach((logLine) -> messages.addObject().put("line", logLine.getMessage())
                .put("timestamp", logLine.getLogTime().toString()).put("host",
                        Optional.fromNullable(logLine.getHost()).transform(Host::getName).or("Deployment")));
        pushLog(node);/*from  w  w w.  ja v a  2  s .com*/
        _lastId = Optional.fromNullable(Iterables.getLast(logs, null)).transform(DeploymentLog::getId)
                .or(_lastId);
        _deployment.refresh();
        _logger.info("Refreshed the deploy, finished=" + _deployment.getFinished());
        if (_deployment.getFinished() != null) {
            pushEnd();
            context().system().scheduler().scheduleOnce(FiniteDuration.apply(10, TimeUnit.SECONDS), self(),
                    "close", context().dispatcher(), self());
        }
    } else if ("close".equals(message)) {
        _channel.eofAndEnd();
        self().tell(PoisonPill.getInstance(), self());
    }
}

From source file:io.gs2.timer.Gs2TimerClient.java

/**
 * ?????<br>//  w  w w. j ava2 s .  co  m
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public CreateTimerPoolResult createTimerPool(CreateTimerPoolRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode().put("name", request.getName());
    if (request.getDescription() != null)
        body.put("description", request.getDescription());

    HttpPost post = createHttpPost(Gs2Constant.ENDPOINT_HOST + "/timerPool", credential, ENDPOINT,
            CreateTimerPoolRequest.Constant.MODULE, CreateTimerPoolRequest.Constant.FUNCTION, body.toString());
    if (request.getRequestId() != null) {
        post.setHeader("X-GS2-REQUEST-ID", request.getRequestId());
    }

    return doRequest(post, CreateTimerPoolResult.class);

}

From source file:net.mostlyharmless.jghservice.connector.jira.CreateIssue.java

@Override
public String getJson() throws JsonProcessingException {
    JsonNodeFactory factory = JsonNodeFactory.instance;
    ObjectNode newNode = factory.objectNode();
    ObjectNode fields = factory.objectNode();

    if (projectKey != null) {
        ObjectNode project = factory.objectNode();
        project.put("key", projectKey);
        fields.put("project", project);
    }//from  w ww. j a  v a 2 s .c  o m

    if (issuetype != null) {
        ObjectNode iType = factory.objectNode();
        iType.put("name", issuetype);
        fields.put("issuetype", iType);
    }

    if (summary != null) {
        fields.put("summary", summary);
    }

    if (description != null) {
        fields.put("description", description);
    }

    if (!fixVersions.isEmpty()) {
        ArrayNode array = factory.arrayNode();
        for (String version : fixVersions) {
            ObjectNode node = factory.objectNode();
            node.put("name", version);
            array.add(node);
        }
        fields.put("fixVersions", array);
    }

    if (!affectsVersions.isEmpty()) {
        ArrayNode array = factory.arrayNode();
        for (String version : affectsVersions) {
            ObjectNode node = factory.objectNode();
            node.put("name", version);
            array.add(node);
        }
        fields.put("versions", array);
    }

    if (assignee != null) {
        ObjectNode node = factory.objectNode();
        if (assignee.isEmpty()) {
            node.put("name", factory.nullNode());
        } else {
            node.put("name", assignee);
        }
        fields.put("assignee", node);
    }

    for (Map.Entry<String, JsonNode> entry : customFields.entrySet()) {
        fields.put(entry.getKey(), entry.getValue());
    }

    newNode.put("fields", fields);

    return new ObjectMapper().writeValueAsString(newNode);

}

From source file:io.gs2.realtime.Gs2RealtimeClient.java

/**
 * ?????<br>// ww w  .  j  a v  a 2s.c om
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public CreateGatheringPoolResult createGatheringPool(CreateGatheringPoolRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode().put("name", request.getName());
    if (request.getDescription() != null)
        body.put("description", request.getDescription());

    HttpPost post = createHttpPost(Gs2Constant.ENDPOINT_HOST + "/gatheringPool", credential, ENDPOINT,
            CreateGatheringPoolRequest.Constant.MODULE, CreateGatheringPoolRequest.Constant.FUNCTION,
            body.toString());
    if (request.getRequestId() != null) {
        post.setHeader("X-GS2-REQUEST-ID", request.getRequestId());
    }

    return doRequest(post, CreateGatheringPoolResult.class);

}

From source file:bz.tsung.jsonapi4j.JsonApiMapper.java

/**
 * Read json api patch ext value./*from   ww  w  .  j av  a2s.  c  o  m*/
 *
 * @param value the value
 * @return the json api document
 * @throws JsonProcessingException the json processing exception
 */
public JsonApiDocument readJsonApiPatchExtValue(JsonNode value) throws JsonProcessingException {
    JsonNode data = JsonNodeFactory.instance.objectNode().set("data", value);
    return mapper.treeToValue(data, JsonApiDocument.class);
}

From source file:io.liveoak.testtools.AbstractHTTPResourceTestCase.java

protected void loadExtension(String id, Extension ext, ObjectNode config) throws Exception {
    ObjectNode fullConfig = JsonNodeFactory.instance.objectNode();
    fullConfig.put("config", config);
    this.system.extensionInstaller().load(id, ext, fullConfig);
    this.extensionIds.add(id);
}

From source file:io.gs2.notification.Gs2NotificationClient.java

/**
 * ?????<br>/*from w  w w  .  java  2s .c  o  m*/
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public CreateNotificationResult createNotification(CreateNotificationRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode().put("name", request.getName());
    if (request.getDescription() != null)
        body.put("description", request.getDescription());

    HttpPost post = createHttpPost(Gs2Constant.ENDPOINT_HOST + "/notification", credential, ENDPOINT,
            CreateNotificationRequest.Constant.MODULE, CreateNotificationRequest.Constant.FUNCTION,
            body.toString());
    if (request.getRequestId() != null) {
        post.setHeader("X-GS2-REQUEST-ID", request.getRequestId());
    }

    return doRequest(post, CreateNotificationResult.class);

}

From source file:com.collective.celos.Util.java

public static ArrayNode newArrayNode() {
    return JsonNodeFactory.instance.arrayNode();
}

From source file:can.yrt.oba.serialization.JacksonSerializer.java

public String toJson(String input) {
    TextNode node = JsonNodeFactory.instance.textNode(input);
    return node.toString();
}