io.syndesis.common.util.Json.toString()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中io.syndesis.common.util.Json.toString()方法的一些代码示例,展示了Json.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.toString()方法的具体详情如下:
包路径:io.syndesis.common.util.Json
类名称:Json
方法名:toString

Json.toString介绍

暂无

代码示例

代码示例来源:origin: io.syndesis.connector/connector-support-processor

@Override
public void process(final Exchange exchange) throws Exception {
  final Message message = exchange.getIn();
  final Object body = message.getBody();
  final JsonNode data = parseBody(body);
  if (data != null) {
    final JsonNode paramMap = data.get("parameters");
    final JsonNode bodyData = data.get("body");
    if (paramMap != null || bodyData != null) {
      if (paramMap != null) {
        for (final String key : parameters) {
          final JsonNode valueNode = paramMap.get(key);
          if (valueNode != null) {
            final String val = valueNode.asText();
            message.setHeader(key, val);
          }
        }
      }
      if (bodyData == null) {
        message.setBody(null);
        return;
      }
      if (bodyData.isContainerNode()) {
        message.setBody(Json.toString(bodyData));
        return;
      }
      message.setBody(bodyData.asText());
    }
  }
}

代码示例来源:origin: io.syndesis.connector/connector-support-processor

@Override
public void process(Exchange exchange) throws Exception {
  final Message message = exchange.getIn();
  final Object body = message.getBody();
  final ObjectNode rootNode = Json.copyObjectMapperConfiguration().createObjectNode();
  if (!parameters.isEmpty()) {
    final ObjectNode parametersNode = rootNode.putObject("parameters");
    for (String parameter : parameters) {
      parametersNode.put(parameter, message.getHeader(parameter, String.class));
    }
  }
  if (body instanceof String) {
    final String string = (String) body;
    if (ObjectHelper.isNotEmpty(string)) {
      rootNode.set("body", READER.readValue(string));
    }
  } else if (body instanceof InputStream) {
    try (InputStream stream = (InputStream) body) {
      if (stream.available() > 0) {
        rootNode.set("body", READER.readValue(stream));
      }
    }
  } else if (body != null) {
    rootNode.putPOJO("body", body);
  }
  final String newBody = Json.toString(rootNode);
  final Message replacement = new DefaultMessage(exchange.getContext());
  replacement.copyFromWithNewBody(message, newBody);
  ExchangeHelper.replaceMessage(exchange, replacement, false);
}

代码示例来源:origin: io.syndesis.server/server-api-generator

byte[] updatedSwagger = Json.toString(swagger).getBytes(StandardCharsets.UTF_8);

相关文章