Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Mode.PROPERTIES still does not support single argument constructor. #38

@hjohn

Description

@hjohn

I have a simple class:

public A {
    private final String title;

    public A(String title) {
        this.title = title;
    }
}

When I serialize this (with private field visibility) I get:

{
  "title" : "Alice in Wonderland",
}

When deserializing (with new ParameterNamesModule(Mode.PROPERTIES)) I however get this exception:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of A (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)

What is ambigious here? There is a creator, but it refuses to use it, even though the properties are matches for the parameter names.

If I add a @JsonProperty annotation or a 2nd parameter, the ambiguity disappears. Is it really impossible to tell Jackson to never ever attempt deserializing by passing in a piece of JSON string text? I never want it to use Mode.DELEGATING...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions