Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Jackson Data Binding Source Code
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".
Jackson Databind Source Code files are provided in the source packge (jackson-databind-2.14.0-sources.jar). You can download it at Jackson Maven Website.
You can also browse Jackson Databind Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java
package com.fasterxml.jackson.databind.ser.std;
import java.io.IOException;
import java.lang.reflect.Type;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.WritableTypeId;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
* Unlike other integral number array serializers, we do not just print out byte values
* as numbers. Instead, we assume that it would make more sense to output content
* as base64 encoded bytes (using default base64 encoding).
*<p>
* NOTE: since it is NOT serialized as an array, cannot use AsArraySerializer as base
*<p>
* NOTE: since 2.6, has been a main-level class; earlier was embedded in
* {@link StdArraySerializers}.
*/
@JacksonStdImpl
public class ByteArraySerializer extends StdSerializer<byte[]>
{
private static final long serialVersionUID = 1L;
public ByteArraySerializer() {
super(byte[].class);
}
@Override
public boolean isEmpty(SerializerProvider prov, byte[] value) {
return value.length == 0;
}
@Override
public void serialize(byte[] value, JsonGenerator g, SerializerProvider provider)
throws IOException
{
g.writeBinary(provider.getConfig().getBase64Variant(),
value, 0, value.length);
}
@Override
public void serializeWithType(byte[] value, JsonGenerator g, SerializerProvider provider,
TypeSerializer typeSer)
throws IOException
{
// most likely scalar
WritableTypeId typeIdDef = typeSer.writeTypePrefix(g,
typeSer.typeId(value, JsonToken.VALUE_EMBEDDED_OBJECT));
g.writeBinary(provider.getConfig().getBase64Variant(),
value, 0, value.length);
typeSer.writeTypeSuffix(g, typeIdDef);
/* OLD impl
typeSer.writeTypePrefixForScalar(value, g);
g.writeBinary(provider.getConfig().getBase64Variant(),
value, 0, value.length);
typeSer.writeTypeSuffixForScalar(value, g);
*/
}
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
ObjectNode o = createSchemaNode("array", true);
ObjectNode itemSchema = createSchemaNode("byte"); //binary values written as strings?
return o.set("items", itemSchema);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
// 14-Mar-2016, tatu: while logically (and within JVM) binary, gets encoded as Base64 String,
// let's try to indicate it is array of Bytes... difficult, thanks to JSON Schema's
// lackluster listing of types
//
// TODO: for 2.8, make work either as String/base64, or array of numbers,
// with a qualifier that can be used to determine it's byte[]
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
}
⏎ com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java
Or download all of them as a single archive file:
File name: jackson-databind-2.14.0-sources.jar File size: 1187952 bytes Release date: 2022-11-05 Download
⇒ Jackson Annotations Source Code
⇐ Download and Install Jackson Binary Package
2022-03-29, ≈229🔥, 0💬
Popular Posts:
JDK 11 jdk.internal.vm.ci.jmod is the JMOD file for JDK 11 Internal VM CI module. JDK 11 Internal VM...
The Jakarta-ORO Java classes are a set of text-processing Java classes that provide Perl5 compatible...
What Is log4j-1.2.13.jar? I got the JAR file from logging-log4j-1.2.13.zip .log4j-1.2.13.jar is the ...
What is the dom\GetElementsByTagName .javaprovided in the Apache Xerces package? I have Apache Xerce...
What Is junit-3.8.1.jar? junit-3.8.1.jar is the version 3.8.1 of JUnit JAR library file. JUnit is a ...