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

JsonProperty index is not honored by CsvSchema builder #115

Closed
kostya-lnk-ms opened this issue Dec 7, 2018 · 2 comments
Closed

JsonProperty index is not honored by CsvSchema builder #115

kostya-lnk-ms opened this issue Dec 7, 2018 · 2 comments
Labels
Milestone

Comments

@kostya-lnk-ms
Copy link

kostya-lnk-ms commented Dec 7, 2018

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);
    }
}
@cowtowncoder cowtowncoder transferred this issue from FasterXML/jackson-dataformat-csv Dec 30, 2018
@cowtowncoder cowtowncoder added 2.10 and removed 2.9 labels Jun 1, 2019
@asyd
Copy link

asyd commented Jul 18, 2019

Same for YAML serializer!

@cowtowncoder
Copy link
Member

Ok: the fix will be via

FasterXML/jackson-databind#2555

included in next minor version, 2.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants