Jackson vs. Gson vs. JSON-B | Annotations comparison

In this article, we will compare Jackson vs. Gson vs. JSON-B [JSR-367] on basis of annotations provides by libraries.

For in depth feature comparison, refer this article.

Jackson vs. Gson vs. JSON-B vs. JSON-P vs. org.JSON vs. Jsonpath | Java JSON libraries features comparison

Feature based Annotations comparison

This comparison is purely based on features provided through annotations. Some of these features might be possible through other means other than annotations with the help of custom code.

Feature Jackson Gson JSON-B
Property name @JsonProperty @SerializedName @JsonbProperty
Ignore / expose property @JsonIgnore
@JsonIgnoreProperties
@JsonIgnoreType
@JsonFilter
@Expose @JsonbTransient
Custom Serializer / Deserializer @JsonSerialize
@JsonDeserialize
@JsonTypeResolver
@JsonAdapter @JsonbTypeAdapter
@JsonbTypeSerializer
@JsonbTypeDeserializer
Versioning @Since
@Until
Property Order @JsonPropertyOrder @JsonbPropertyOrder
Custom object instantiation @JsonCreator @JsonbCreator
Null / Empty handling @JsonInclude
(ALWAYS, NON_ABSENT, NON_DEFAULT, NON_EMPTY, NON_NULL)
@JsonbNillable
Value formatting @JsonFormat
(Date, Enum, Collection)
@JsonbDateFormat
@JsonbNumberFormat
Access level Visibility strategy @JsonAutoDetect @JsonbVisibility
Polymorphic type handling @JsonTypeInfo
@JsonSubTypes
@JsonSubTypes.Type
Inject values @JacksonInject
Identity based serialization @JsonIdentityInfo
@JsonIdentityReference
Many views of same JSON @JsonView
Include instance properties in parent object @JsonUnwrapped
Raw value serialization @JsonRawValue

 

Leave a Reply

Your email address will not be published. Required fields are marked *