MultiPolygon implements CoordinateContainer<List<List<List<Point>>>> { @Override public String toJson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().toJson(this); } MultiPolygon(String type, @Nullable BoundingBox bbox, List<List<List<Point>>> coordinates); static MultiPolygon fromJson(String json); static MultiPolygon fromPolygons(@NonNull List<Polygon> polygons); static MultiPolygon fromPolygons(@NonNull List<Polygon> polygons,
                                          @Nullable BoundingBox bbox); static MultiPolygon fromPolygon(@NonNull Polygon polygon); static MultiPolygon fromPolygon(@NonNull Polygon polygon, @Nullable BoundingBox bbox); static MultiPolygon fromLngLats(@NonNull List<List<List<Point>>> points); static MultiPolygon fromLngLats(@NonNull List<List<List<Point>>> points,
                                         @Nullable BoundingBox bbox); List<Polygon> polygons(); @NonNull @Override String type(); @Nullable @Override BoundingBox bbox(); @NonNull @Override List<List<List<Point>>> coordinates(); @Override String toJson(); static TypeAdapter<MultiPolygon> typeAdapter(Gson gson); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void toJson() throws IOException { final String json = "{\"type\":\"MultiPolygon\",\"coordinates\": " + " [[[[102, 2], [103, 2], [103, 3], [102, 3], [102, 2]]]," + " [[[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]]," + " [[100.2, 0.2], [100.2, 0.8], [100.8, 0.8], [100.8, 0.2], [100.2, 0.2]]]]}"; MultiPolygon geo = MultiPolygon.fromJson(json); compareJson(json, geo.toJson()); }