Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

FeatureCollection.fromJson() should also accept a 'Reader' parameter

Open
#1,136 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Read services-geojson/src/main/java/com/mapbox/geojson/FeatureCollection.java and the existing fromJson(String) entry point. Add the Reader overload using the shown Gson adapter setup, then run the relevant project tests and confirm that Reader input produces a FeatureCollection without changing the existing String behavior.

Written by the indexing model from the issue text.

Description

GeoJson

Currently a FeatureCollection can not be instantiated from a Reader.
The only function provided requires a String in JSON format as can be seen here.

Such approach is inefficient when reading larger files since the entire file content has to be read and stored in memory before it can be transformed into a FeatureCollection.
If a FeatureCollection could be instantiated from a Reader aswell, only parts of the read file would have to be stored in memory which makes this the more desirable approach in the presented situation.

As the used GSON library already enables the use of a Reader instead of a String, the implementation would be very simple and could look like this:

@Nullable
public static FeatureCollection fromJson(@NonNull Reader reader) { 
  GsonBuilder gson = new GsonBuilder();
  gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create());
  gson.registerTypeAdapterFactory(GeometryAdapterFactory.create());
  return gson.create().fromJson(reader, FeatureCollection.class);
}
Dominant language
Java
Stars
438
Forks
117
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/mapbox-java

All issues in mapbox/mapbox-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.