Exception while deserializing `SingletonList`
Sekky61 opened this issue · comments
Sekky61 commented
If this is known behavior, I suggest documenting it more clearly.
Note, that changing Collections.singletonList
for List.of
works without a problem.
Version: 4.14.1
Test for reproduction:
@Test
public void testSingletonListSerialization()
{
// Simple object with a list field, behaves the same with a class
record Foo(List<String> list) { }
// Serialize foo with a singletonList, then deserialization throws
Foo foo = new Foo(Collections.singletonList("bar"));
String json = JsonWriter.objectToJson(foo);
// Problem is here:
Assert.assertThrows(JsonIoException.class, () -> JsonReader.jsonToJava(json));
}
John DeRegnaucourt commented
This has been fixed and will be released in json-io 4.16.0.