-
-
Notifications
You must be signed in to change notification settings - Fork 152
Closed
Description
In the case if I don't want to use JsonPropertyOrder, which looks to be less convenient than use "index" property:
Properties are ordered alphabetically, (regardless of their "index" values), so the test failing with 2.9.7
According to the index documentation, it should be used for schema generation:
"Property that indicates numerical index of this property (relative
* to other properties specified for the Object). This index
* is typically used by binary formats, but may also be useful
* for schema languages and other tools."
public class CsvTest {
public static class Pojo {
@JsonProperty(required = true, value = "Name", index = 1)
private String name;
@JsonProperty(required = true, value = "Abba", index = 2)
private int ab;
}
@Test
public void tt() throws IOException {
String csvText = "Name,Abba\n" + "Alex, 1\n";
CsvMapper mapper = new CsvMapper();
CsvSchema schema = mapper
.schemaFor(Pojo.class)
.withHeader()
.withStrictHeaders(true);
List<Pojo> out = mapper.readerFor(Pojo.class).with(schema).<Pojo>readValues(csvText).readAll();
assertEquals(out.size(), 1);
}
}
Grundlefleck and asyd