java icon indicating copy to clipboard operation
java copied to clipboard

Jsoniter doesn't support Java 16 records

Open knl opened this issue 4 years ago • 4 comments

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)
{
}

knl avatar Sep 02 '21 21:09 knl

Hi @knl

Since the last commit here was in 2019 I doubt that Json Iterator supports latest Java features like records, etc.

sergey-morenets avatar Oct 04 '21 20:10 sergey-morenets

True that, I didn't take a look at the last commit. Is this a dead project then?

knl avatar Nov 03 '21 17:11 knl

@knl Not sure but you can always ask authors of this libraries

sergey-morenets avatar Nov 03 '21 19:11 sergey-morenets

I am from a student group from kth stockholm, trying to solve this issue as a homework. Could you @taowen add me as an assignee?

lnsandnkth avatar Feb 28 '22 15:02 lnsandnkth