Polygon implements CoordinateContainer<List<List<Point>>> { @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } Polygon(String type, @Nullable BoundingBox bbox, List<List<Point>> coordinates); static Polygon fromJson(@NonNull String json); static Polygon fromLngLats(@NonNull List<List<Point>> coordinates); static Polygon fromLngLats(@NonNull List<List<Point>> coordinates,
                                    @Nullable BoundingBox bbox); static Polygon fromOuterInner(@NonNull LineString outer, @Nullable LineString... inner); static Polygon fromOuterInner(@NonNull LineString outer, @Nullable BoundingBox bbox,
                                       @Nullable LineString... inner); static Polygon fromOuterInner(@NonNull LineString outer,
                                       @Nullable @Size(min = 1) List<LineString> inner); static Polygon fromOuterInner(@NonNull LineString outer, @Nullable BoundingBox bbox,
                                       @Nullable @Size(min = 1) List<LineString> inner); @Nullable LineString outer(); @Nullable List<LineString> inner(); @NonNull @Override String type(); @Nullable @Override BoundingBox bbox(); @NonNull @Override List<List<Point>> coordinates(); @Override String toJson(); static TypeAdapter<Polygon> typeAdapter(Gson gson); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void toJson() throws IOException { final String json = "{\"type\": \"Polygon\", " + "\"coordinates\": [[[100, 0], [101, 0], [101, 1], [100, 1],[100, 0]]]}"; Polygon geo = Polygon.fromJson(json); compareJson(json, geo.toJson()); }