-
Notifications
You must be signed in to change notification settings - Fork 224
Open
Labels
triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
I kept getting the error where I couldn't unmarshal a saved sample data because for some reason it would think Route.Legs is a type of string. I modified the code to test it directly right after getting a response, but still the same issue.
Environment details
- Specify the API at the beginning of the title (for example, "Places: ...")
- OS type and version
- Library version and other environment information
- googlemaps.github.io/maps v1.3.2 (the latest)
- go version go1.16.5 darwin/amd64
Steps to reproduce
- Get []map.Route from valid client request through the Directions API
- Marshal the object
- Unmarshal the same object
Code example
routes := getSampleRoutes()
jsonObj, err := json.MarshalIndent(routes, "", " ")
if err != nil {
log.Fatal(err)
}
// At this point, I was able to check that the proper data came through and that the object was marshalled properly
var newRoutes []maps.Route
err = json.Unmarshal(jsonObj, &newRoutes)
if err != nil {
log.Fatal(err) // hits error here
}
Stack trace
fatal error: json: cannot unmarshal object into Go struct field Route.legs of type string
Metadata
Metadata
Assignees
Labels
triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.