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

Serialization of List<Feature> does not include type #50

Open
rmpt opened this issue Apr 10, 2019 · 1 comment
Open

Serialization of List<Feature> does not include type #50

rmpt opened this issue Apr 10, 2019 · 1 comment

Comments

@rmpt
Copy link

rmpt commented Apr 10, 2019

Serialization of feature lists should include the feature type. We are forced to use a FeatureCollection to the type be included in the serialization.

List<Feature> features = new ArrayList<>();
features.add(new Feature());
String json = new ObjectMapper().writeValueAsString(features);
System.out.println(json);
// output: [{"properties":{},"geometry":null}]
@hylkevds
Copy link

hylkevds commented Aug 3, 2022

In case someone else runs into this, more background information can be found in this issue: FasterXML/jackson-databind#1015

Workaround: instead of using List<Feature>, use:

private static class FeatureList extends ArrayList<GeoJsonObject> {};
private final FeatureList features = new FeatureList();

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

No branches or pull requests

2 participants