-
-
Notifications
You must be signed in to change notification settings - Fork 201
Open
Description
There appears to be an under-the-hood inconsistency between a Wrap()-derived container and a New()-derived container. This causes both .Delete() and .DeleteP() to fail when called on Wrap()-derived containers.
Clock the following samples:
New
jObj := gabs.New()
jObj.Set(1, "A")
jObj.SetP(2, "B")
if err := jObj.Delete("B"); err != nil {
panic(err)
}
fmt.Println(jObj.String())This works as intended, returning {"A":1}.
Wrap
type t struct {
A int
B int
}
wrap := gabs.Wrap(t{A: 1, B: 2})
if err := wrap.Delete("B"); err != nil {
panic(err)
}
fmt.Println(wrap)This, however, panics, returning a 'not an object or array' error.
The difference occurs at gabs.go:471.
The New snippet has an actual map to operate on, containing map[string]interface {} {"A": 1, "B": 2} beneath the hood.
The Wrap container, however, is just data{A: 1, B: 2} and therefore fails the map type assertion.
I currently have a PR in the works to fix this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels