payload.Get(<path>) support ! -> . (dot) separated paths are now supported by payload.Get()
Pre-release
Pre-release
Support for . (dot) separated paths in the payload objects
Examples:
//convenient access
p.Get("address.street").String()
// indexed arrays
p.Get("address.options[0].label").String()
p := New(map[string]interface{}{
"name": "John",
"lastname": "Snow",
"address": M{
"street": "jonny ave",
"country": M{
"code": "NZ",
"name": "New Zealand",
},
"options": []M{
M{
"label": "item 1",
},
M{
"label": "item 2",
},
},
},
})
Expect(p.Get("name").String()).Should(Equal("John"))
Expect(p.Get("address.street").String()).Should(Equal("jonny ave"))
Expect(p.Get("address.country.code").String()).Should(Equal("NZ"))
Expect(p.Get("address.options[0].label").String()).Should(Equal("item 1"))
Expect(p.Get("address.options[1].label").String()).Should(Equal("item 2"))
})