Skip to content

Jsoniter doesn't support Java 16 records #302

Open
@knl

Description

@knl

When I try to deserialize a record, I get the following error:

com.jsoniter.spi.JsonException: no constructor for: class ch.knezevic.school.LastDone
	at ch.knezevic.school.FeedTest.shouldDecodeLastDone(FeedTest.java:67)

The test looks like this:

    private static final String SAMPLE_LAST_DONE_MESSAGE = """
        {
          "timestamp":0,
          "book":"book",
          "price":1000,
          "volume":10
        }
        """;

    @Test
    public void shouldDecodeLastDone()
    {
        final LastDone lastDone = JsonIterator.deserialize(SAMPLE_LAST_DONE_MESSAGE, LastDone.class);
        assertEquals("book", lastDone.book());
    }

LastDone is defined as:

public record LastDone(String book, int price, long volume, long timestamp)
{
}

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