Skip to content
Advertisement

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

Gson showing nested Object as null

Im trying to deserialize objects into JSON, one object contains a nested object. I created an instance of both the nested object (UserAddress)and the one containing it (UserObjectWithNestedObject). However, when I serialize, the nested object is null. So I ran the program in debugger mode to see when it goes null. It seems to be null when I use it

Spring Integration: how to configure ObjectToJsonTransformer to add json__TypeId__ with class name instead of canonical name

I am trying to serialize a message (then deserialize it) and I do not want any of the headers json__TypeId__ or json_resolvableType to contain the canonical name of the class. This is because I am sending the message over the network and I consider including the canonical name in the header a security concern. Here is just the relevant parts

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

Java record serialization and repeated calls to canonical constructor

In this post about serializable records it is stated that Deserialization creates a new record object by invoking a record class’s canonical constructor, passing values deserialized from the stream as arguments to the canonical constructor. This is secure because it means the record class can validate the values before assigning them to fields, just like when an ordinary Java program

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

Advertisement