Support for generic types when serializing and deserializing?

Issue #387 new
Bartłomiej Mazur
created an issue

Currently SnakeYaml only support beans deserialization via:

public <T> T loadAs(String yaml, Class<T> type)

This make near impossible to write some own library for some serialization/deserialization using snakeyaml, especially if data isn't made by us and does not contain type tags in it.

It would be awesome to be able to use methods like this:

public <T> T loadAs(String yaml, Type type)
public String dumpAs(Object object, Type type) // will not include type tags for known types that can be read from generic

Just like in GSON library.

As I see you often want to see some test cases describing issue, I attached one, but ofc code will not compile, as this is request for new methods that will support that features. Test requires GSON, as I didn't want to include whole TypeToken<T> API.

Comments (3)

  1. Log in to comment