-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
I created a simple program that tests the ParameterNamesModule
in java 8, jackson version 2.9.7. Unfortunately I receive the error "Cannot construct instance of Main$Track
(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator).
This same example works fine when manually annotating the constructor with @JsonCreator
, and parameters with @JsonParameter
.
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import java.io.IOException;
import static com.fasterxml.jackson.databind.PropertyNamingStrategy.SNAKE_CASE;
public class Main {
public static final class Track {
public final int id;
public final String name;
public final String artist;
public Track(int id, String name, String artist) {
this.id = id;
this.name = name;
this.artist = artist;
}
@Override
public String toString() {
return String.format("id: %d, name: %s, artist: %s", id, name, artist);
}
}
public static void main(String[] args) throws IOException {
ObjectMapper om = new ObjectMapper()
.registerModule(new ParameterNamesModule())
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule())
.setPropertyNamingStrategy(SNAKE_CASE);
String json = "{\"id\": 345, \"name\": \"Inside Out\", \"artist\": \"Spoon\"}";
Track t = om.readValue(json, Track.class);
System.out.println(t);
}
}
Is the module not being registered? Or am I not using ParamNamesModule correctly?
Metadata
Metadata
Assignees
Labels
No labels