Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduce issue with JavaType ObjectMapper Test #225

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public VavrDeserializers(VavrModule.Settings settings) {
this.settings = settings;
}

@SuppressWarnings("deprecation")
@Override
public JsonDeserializer<?> findBeanDeserializer(JavaType type,
DeserializationConfig config,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package io.vavr.jackson.datatype.seq;

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import io.vavr.collection.List;
import io.vavr.jackson.datatype.VavrModule;
import org.junit.jupiter.api.Test;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

class JavaTypeObjectMapperTest {

@Test
void shouldDeserializeList() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new VavrModule());
Type type = new ParameterizedType() {
@Override
public Type[] getActualTypeArguments() {
return new Type[]{XY.class};
}

@Override
public Type getRawType() {
return List.class;
}

@Override
public Type getOwnerType() {
return null;
}
};
JavaType a = TypeFactory.defaultInstance().constructType(type);
List<?> list = mapper.readValue("[{\"x\":1,\"y\":2},{\"x\":3,\"y\":4}]", a);
}

static class XY {
private int x, y;

public XY() {
}

public XY(int x, int y) {
this.x = x;
this.y = y;
}

public int getX() {
return x;
}

public void setX(int x) {
this.x = x;
}

public int getY() {
return y;
}

public void setY(int y) {
this.y = y;
}
}
}
Loading