Skip to content

@JsonValue fails for Java Record #3063

@cowwoc

Description

@cowwoc

Version information
2.12.1
OpenJDK 15.0.1

To Reproduce

Given:

public final record GetLocations(@JsonValue Map<String, URI> nameToLocation)
{
	@JsonCreator
	public GetLocations(Map<String, URI> nameToLocation)
	{
		assertThat(nameToLocation, "nameToLocation").isNotNull();
		this.nameToLocation = new HashMap<>(nameToLocation);
	}
}

I am expecting Jackson to serialize the Map to JSON but instead I get the following exception:

Problem with definition of [AnnotedClass GetLocations]: Multiple 'as-value' properties defined ([field GetLocations#nameToLocation] vs [method GetLocations#nameToLocation()])

Metadata

Metadata

Assignees

No one assigned

    Labels

    RecordIssue related to JDK17 java.lang.Record support

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions