Not able to parse response for optimization or direction API for .geometries("geojson")
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 438
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
if I add .geometries("geojson") as routeOption in
https://github.com/mapbox/mapbox-java/blob/main/samples/src/main/java/com/mapbox/samples/BasicDirections.java
or
https://github.com/mapbox/mapbox-java/blob/main/samples/src/main/java/com/mapbox/samples/BasicOptimization.java
It throws an error
Expected a string but was BEGIN_OBJECT at line 1 column 412 path $.trips[0].geometry
Where as it works when we call via API playground or use polyline6 as geometry.
Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 412 path $.trips[0].geometry
at com.google.gson.stream.JsonReader.nextString(JsonReader.java:824) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.TypeAdapters$15.read(TypeAdapters.java:380) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.TypeAdapters$15.read(TypeAdapters.java:368) ~[gson-2.8.9.jar:na]
at com.mapbox.api.directions.v5.models.AutoValue_DirectionsRoute$GsonTypeAdapter.read(AutoValue_DirectionsRoute.java:223) ~[mapbox-sdk-directions-models-6.3.0.jar:na]
at com.mapbox.api.directions.v5.models.AutoValue_DirectionsRoute$GsonTypeAdapter.read(AutoValue_DirectionsRoute.java:31) ~[mapbox-sdk-directions-models-6.3.0.jar:na]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) ~[gson-2.8.9.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[gson-2.8.9.jar:na]
at com.mapbox.api.optimization.v1.models.AutoValue_OptimizationResponse$GsonTypeAdapter.read(AutoValue_OptimizationResponse.java:115) ~[mapbox-sdk-services-6.3.0.jar:na]
at com.mapbox.api.optimization.v1.models.AutoValue_OptimizationResponse$GsonTypeAdapter.read(AutoValue_OptimizationResponse.java:28) ~[mapbox-sdk-services-6.3.0.jar:na]
I am using mapbox-sdk-core-6.3.0.jar
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with samples/src/main/java/com/mapbox/samples/BasicDirections.java and BasicOptimization.java, reproduce the failure using geometries("geojson"), and inspect the response at trips[0].geometry. Compare the object returned for GeoJSON with the string returned for polyline6; done means both Directions and Optimization responses parse without the Gson exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100