本文整理了Java中com.fasterxml.jackson.databind.JsonNode.binaryValue()
方法的一些代码示例,展示了JsonNode.binaryValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.binaryValue()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:binaryValue
[英]Method to use for accessing binary content of binary nodes (nodes for which #isBinary returns true); or for Text Nodes (ones for which #textValue returns non-null value), to read decoded base64 data. For other types of nodes, returns null.
[中]用于访问二进制节点(即#isBinary返回true的节点)的二进制内容的方法;或者对于文本节点(那些#textValue返回非空值的节点),读取解码的base64数据。对于其他类型的节点,返回null。
代码示例来源:origin: line/armeria
@Override
public ByteBuffer readFromJsonElement(JsonNode elem) {
try {
return ByteBuffer.wrap(elem.binaryValue());
} catch (IOException e) {
throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e);
}
}
代码示例来源:origin: twosigma/beakerx
@Override
public Object deserialize(JsonNode n, ObjectMapper mapper) {
Object o = null;
try {
if (n.has("imageData")) {
byte [] data = n.get("imageData").binaryValue();
o = Images.decode(data);
}
} catch (Exception e) {
logger.error("exception deserializing ImageIcon ", e);
}
return o;
}
代码示例来源:origin: redisson/redisson
@Override
public byte[] getBinaryValue(Base64Variant b64variant)
throws IOException, JsonParseException
{
// Multiple possibilities...
JsonNode n = currentNode();
if (n != null) {
// [databind#2096]: although `binaryValue()` works for real binary node
// and embedded "POJO" node, coercion from TextNode may require variant, so:
if (n instanceof TextNode) {
return ((TextNode) n).getBinaryValue(b64variant);
}
return n.binaryValue();
}
// otherwise return null to mark we have no binary content
return null;
}
代码示例来源:origin: prestodb/presto
private Object toValue(JsonNode node)
throws IOException
{
if (node.isTextual()) {
return node.asText();
}
else if (node.isNumber()) {
return node.numberValue();
}
else if (node.isBoolean()) {
return node.asBoolean();
}
else if (node.isBinary()) {
return node.binaryValue();
}
else {
throw new IllegalStateException("Unexpected range bound value: " + node);
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
case BINARY:
try {
return read.binaryValue();
} catch (IOException e) {
return null;
代码示例来源:origin: Netflix/conductor
@Override
public Any deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonNode root = p.getCodec().readTree(p);
JsonNode type = root.get(JSON_TYPE);
JsonNode value = root.get(JSON_VALUE);
if (type == null || !type.isTextual()) {
throw ctxt.reportMappingException("invalid '@type' field when deserializing ProtoBuf Any object");
}
if (value == null || !value.isTextual()) {
throw ctxt.reportMappingException("invalid '@value' field when deserializing ProtoBuf Any object");
}
return Any.newBuilder()
.setTypeUrl(type.textValue())
.setValue(ByteString.copyFrom(value.binaryValue()))
.build();
}
}
代码示例来源:origin: apache/usergrid
return wrap( json.binaryValue());
代码示例来源:origin: apache/usergrid
return wrap( json.binaryValue() );
代码示例来源:origin: palantir/atlasdb
@Override
public TableRange deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode node = jp.readValueAsTree();
String tableName = node.get("table").textValue();
TableMetadata metadata = metadataCache.getMetadata(tableName);
JsonNode optBatchSize = node.get("batch_size");
int batchSize = optBatchSize == null ? 2000 : optBatchSize.asInt();
Iterable<byte[]> columns = AtlasDeserializers.deserializeNamedCols(metadata.getColumns(), node.get("cols"));
byte[] startRow = new byte[0];
byte[] endRow = new byte[0];
if (node.has("prefix")) {
startRow = AtlasDeserializers.deserializeRowPrefix(metadata.getRowMetadata(), node.get("prefix"));
endRow = RangeRequests.createEndNameForPrefixScan(startRow);
} else {
if (node.has("raw_start")) {
startRow = node.get("raw_start").binaryValue();
} else if (node.has("start")) {
startRow = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), node.get("start"));
}
if (node.has("raw_end")) {
endRow = node.get("raw_end").binaryValue();
} else if (node.has("end")) {
endRow = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), node.get("end"));
}
}
return new TableRange(tableName, startRow, endRow, columns, batchSize);
}
}
代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9-shaded
@Override
public ByteBuffer readFromJsonElement(JsonNode elem) {
try {
return ByteBuffer.wrap(elem.binaryValue());
} catch (IOException e) {
throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e);
}
}
代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9
@Override
public ByteBuffer readFromJsonElement(JsonNode elem) {
try {
return ByteBuffer.wrap(elem.binaryValue());
} catch (IOException e) {
throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e);
}
}
代码示例来源:origin: baidubce/bce-sdk-java
@JsonIgnore
public byte[] getBytesValue(int index) throws IOException {
return value.get(index).binaryValue();
}
代码示例来源:origin: com.linecorp.armeria/armeria-thrift
@Override
public ByteBuffer readFromJsonElement(JsonNode elem) {
try {
return ByteBuffer.wrap(elem.binaryValue());
} catch (IOException e) {
throw new IllegalArgumentException("Error decoding binary value, is it valid base64?", e);
}
}
代码示例来源:origin: Yubico/java-webauthn-server
private static List<X509Certificate> getX5c(JsonNode header) throws IOException, CertificateException {
List<X509Certificate> result = new ArrayList<>();
for (JsonNode jsonNode : header.get("x5c")) {
result.add(CertificateParser.parseDer(jsonNode.binaryValue()));
}
return result;
}
}
代码示例来源:origin: com.xiaomi.infra.galaxy/galaxy-olap-sdk-java
@Override
public byte[] getBytes(int columnIndex) throws SQLException {
JsonNode ret = getColumnValue(columnIndex);
if (wasNull) {
return null;
}
try {
return ret.binaryValue();
} catch (IOException e) {
throw new SQLException("error converting binary data", e);
}
}
代码示例来源:origin: org.echocat.marquardt/common
@Override
public PublicKey deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException {
final ObjectCodec oc = jsonParser.getCodec();
final JsonNode node = oc.readTree(jsonParser);
return new PublicKeyWithMechanism(node.get(PublicKeySerializer.KEY).binaryValue()).toJavaKey();
}
}
代码示例来源:origin: lightblue-platform/lightblue-core
@Override
public Object fromJson(JsonNode node) {
if (node == null || node instanceof NullNode) {
return null;
} else if (node.isValueNode()) {
try {
return node.binaryValue();
} catch (Exception e) {
}
}
throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString());
}
代码示例来源:origin: com.redhat.lightblue/lightblue-core-metadata
@Override
public Object fromJson(JsonNode node) {
if (node == null || node instanceof NullNode) {
return null;
} else if (node.isValueNode()) {
try {
return node.binaryValue();
} catch (Exception e) {
}
}
throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString());
}
代码示例来源:origin: com.redhat.lightblue/metadata
@Override
public Object fromJson(JsonNode node) {
if (node.isValueNode()) {
try {
return node.binaryValue();
} catch (Exception e) {
}
}
throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, node.toString());
}
代码示例来源:origin: Yubico/java-webauthn-server
private static ByteArray getResponseBytes(AttestationObject attestationObject) {
final JsonNode response = attestationObject.getAttestationStatement().get("response");
if (response == null || !response.isBinary()) {
throw new IllegalArgumentException("Property \"response\" of android-safetynet attestation statement must be a binary value, was: " + response);
}
try {
return new ByteArray(response.binaryValue());
} catch (IOException ioe) {
throw ExceptionUtil.wrapAndLog(log, "response.isBinary() was true but response.binaryValue failed: " + response, ioe);
}
}
内容来源于网络,如有侵权,请联系作者删除!