Skip to content

Tag: jackson

How do I stop jackson’s YAML writer from quoting values

I’m working on a project to convert files from JSON to YAML. I’m using the 2.8.3 versions of the following libraries: jackson-core jackson-databind jackson-dataformat-yaml jackson-annotations My YAML serialization code is extremely simple: The YAML produced by this code looks like the following: A…

Jackson Serialize Field to Different Name

I have this JSON to deserialize: I want to serialize it to 2 different formats: [A] [B] I’m able to serialize it to 1 format: [A] only or [B] only. Here’s my code to serialize it to [B]: I read about JsonView here http://www.baeldung.com/jackson-json-view-annotation (section ‘5. Customize JS…

How to serialize nested ObjectId to String with Jackson?

There are many questions concerning conversion from ObjectId to String with jackson. All answers suggest either creating own JsonSerializer<ObjectId> or annotating the ObjectId field with @JsonSerialize(using = ToStringSerializer.class). However, I have a map that sometimes contains ObjectIds, i.e.: I w…

Using spring converter in @RequestBody

Is it possible to enforce Converter ( org.springframework.core.convert.converter.Converter) to finish json object mapping? Json code example: where somename – string, id – integer value mapping to : Converter code example: What I want to achieve is to map that json to the object which will have au…

Jackson – Custom TypeId Resolver

I’ve been using a custom typeId resolver for one of my classes, so far I’ve been leaning on the annotation support: But now I need to customize the creation of the type resolver by passing some other dependencies to it via constructor or setters, and since Jackson is the one who instantiate it I c…