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