Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Implement #11: default to alphabetic sorting of properties
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 10, 2013
1 parent 23e74fb commit 84407c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Project: jackson-dataformat-csv
Version: 2.3.0 (xx-xxx-2013)

#11: Default `CsvMapper` to use alphabetic sorting of properties (since
alternative is basically undefined; and with JDK 1.7+, unstable too)
- Add support for `JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN`

------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
import com.fasterxml.jackson.databind.util.NameTransformer;
import com.fasterxml.jackson.core.type.TypeReference;

import com.fasterxml.jackson.dataformat.csv.impl.LRUMap;

/**
Expand Down Expand Up @@ -42,6 +41,8 @@ public CsvMapper()
public CsvMapper(CsvFactory f)
{
super(f);
// As per #11: default to alphabetic ordering
enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public Location(int x, int y) {
}
}

// IMPORTANT: ordering DOES matter here
@JsonPropertyOrder({ "name", "location" })
static class Unwrapping {
public String name;
@JsonUnwrapped(prefix="loc.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.*;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.MapperFeature;

public class TestVersions extends ModuleTestBase
{
Expand All @@ -18,6 +19,13 @@ public void testMapperVersions() throws IOException
jgen.close();
}

// Mostly to verify #11
public void testMapperDefaults()
{
CsvMapper mapper = new CsvMapper();
assertTrue(mapper.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY));
}

/*
/**********************************************************
/* Helper methods
Expand Down

0 comments on commit 84407c9

Please sign in to comment.