Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
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 (309)
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/BooleanSerializer.java
package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContextualSerializer; /** * Serializer used for primitive boolean, as well as java.util.Boolean * wrapper type. *<p> * Since this is one of "natural" (aka "native") types, no type information is ever * included on serialization (unlike for most other scalar types) */ @JacksonStdImpl public final class BooleanSerializer //In 2.9, removed use of intermediate type `NonTypedScalarSerializerBase` extends StdScalarSerializer<Object> implements ContextualSerializer { private static final long serialVersionUID = 1L; /** * Whether type serialized is primitive (boolean) or wrapper * (java.lang.Boolean); if true, former, if false, latter. */ protected final boolean _forPrimitive; public BooleanSerializer(boolean forPrimitive) { super(forPrimitive ? Boolean.TYPE : Boolean.class, false); _forPrimitive = forPrimitive; } @Override public JsonSerializer<?> createContextual(SerializerProvider serializers, BeanProperty property) throws JsonMappingException { // 16-Mar-2021, tatu: As per [databind#3080], was passing wrapper type // always; should not have. JsonFormat.Value format = findFormatOverrides(serializers, property, handledType()); if (format != null) { JsonFormat.Shape shape = format.getShape(); if (shape.isNumeric()) { return new AsNumber(_forPrimitive); } if (shape == JsonFormat.Shape.STRING) { return new ToStringSerializer(_handledType); } } return this; } @Override public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeBoolean(Boolean.TRUE.equals(value)); } @Override public final void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { g.writeBoolean(Boolean.TRUE.equals(value)); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("boolean", !_forPrimitive); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectBooleanFormat(typeHint); } /** * Alternate implementation that is used when values are to be serialized * as numbers <code>0</code> (false) or <code>1</code> (true). * * @since 2.9 */ final static class AsNumber extends StdScalarSerializer<Object> implements ContextualSerializer { private static final long serialVersionUID = 1L; /** * Whether type serialized is primitive (boolean) or wrapper * (java.lang.Boolean); if true, former, if false, latter. */ protected final boolean _forPrimitive; public AsNumber(boolean forPrimitive) { super(forPrimitive ? Boolean.TYPE : Boolean.class, false); _forPrimitive = forPrimitive; } @Override public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeNumber((Boolean.FALSE.equals(value)) ? 0 : 1); } @Override public final void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { // 27-Mar-2017, tatu: Actually here we CAN NOT serialize as number without type, // since with natural types that would map to number, not boolean. So choice // comes to between either add type id, or serialize as boolean. Choose // latter at this point g.writeBoolean(Boolean.TRUE.equals(value)); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { // 27-Mar-2017, tatu: As usual, bit tricky but... seems like we should call // visitor for actual representation visitIntFormat(visitor, typeHint, NumberType.INT); } @Override public JsonSerializer<?> createContextual(SerializerProvider serializers, BeanProperty property) throws JsonMappingException { JsonFormat.Value format = findFormatOverrides(serializers, property, Boolean.class); if (format != null) { JsonFormat.Shape shape = format.getShape(); if (!shape.isNumeric()) { return new BooleanSerializer(_forPrimitive); } } return this; } } }
⏎ com/fasterxml/jackson/databind/ser/std/BooleanSerializer.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, 48329👍, 0💬
Popular Posts:
JDK 11 jdk.crypto.mscapi.jmod is the JMOD file for JDK 11 Crypto MSCAPI module. JDK 11 Crypto MSCAPI...
What Is mail.jar of JavaMail 1.3? I got the JAR file from javamail-1_3.zip. mail.jar in javamail-1_3...
How to download and install Apache ZooKeeper Source Package? Apache ZooKeeper is an open-source serv...
What Is in Xerces-J-bin.2.12.2.zip? Xerces-J-bin.2.12.2.zip file is the distribution package ZIP fil...
What Is javamail-1_2.zip? javamail-1_2.zip is the binary package of JavaMail API 1.2 in ZIP format. ...