Skip to content

Tag: serialization

@JsonIdentityInfo serialization of items

I’m trying to serialize relations using @JsonItentityInfo to avoid circular references. I’ve created a test to try test the result of the serialization, and I’ve found that jackson is not behaving as I expected. The serialization in not what I though it would be and, in fact, when I try to desarialize the serializated object, an exception is thrown. The

Why is there a “topic” parameter in the overridden serialize() method from Serializer interface in org.apache.kafka.common.serialization

I have observed that implementations of the method serialize() of the Serializer<> interface has two parameters: byte[] serialize(String topic, T data) but the method body does not require String topic parameter at all. So why does it exist? Sample Implementation available in the package org.apache.kafka.common.serialization: Answer In this specific implementation, indeed there’s no usage. Yet, this parameter may be used

ObjectMapper writeValueAsString on ‘null’ vs ‘NullNode.getInstance()’

Consider the following statements: String s1 = new ObjectMapper().writeValueAsString(null); String s2 = new ObjectMapper().writeValueAsString(NullNode.getInstance()); In both the cases, serialized values s1 and s2 would be “null” (in String format). Jackson, by default, serializes null objects without any exception. What are the cases where we need to use NullNode, instead of directly serializing null? Answer “null” here is a string, not