Skip to content
Advertisement

Tag: deserialization

How to parse TOML document with Java

In my Java app I get a TOML document from REST service response as String and I look how to parse it and convert to Java objects. Ideally I’d like to use some existing mapper library for deserialization, something like Jackson or Gson for JSON objects. Are there any options in Java ecosystem for that? Answer There are several libraries

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

Adding custom arguments to Jackson deserializer

I have a custom deserializer. But I want to be able to pass additional arguments. For example How can I pass in my custom parameter on the annotation? Answer You cannot add your own parameters to @JsonDeserialize, because you can’t alter Jackson’s implementation of this annotation. However, you can achieve your goal in a slightly different way. You can invent

Get object from .readEntity

I have a java service which calls an API and gets the following in return How can i use .readEntity (or something else) to get the object for a given field; say service2 Or just convert all objects inside status to a List<> of objects String output = response.readEntity(String.class); works, but i dont know how to parse it properly to

Jackson deserialization: Can I inject a value with an annotation on the field of the to deserializable object?

I have an object like this to deserialize: whereas the class Relation looks like this: RelationType is en enum and is not a value which will be deserialized, while all others are. Is it possible, that I could “inject” the enum value for the field relationType with an annotation on the field in the class RelationInput? Like the following Does

Abstract class with Gson serialization/deserialization

I am expecting to get from a json a LinkedList<Request>. The pojos look like this: The serialization works fine, it generates the json, but it crashes at deserialization (maybe it’s the abstract class or/and that I am expecting a LinkedList and/or the lombok annotations)? I tryed writting a gson deserializer (quite a standard one found googling), but it doesn’t do

Advertisement