Skip to content

Commit

Permalink
Added method GetProperty for Object struct
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaksv committed Feb 8, 2021
1 parent d4d4a34 commit c86f176
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dynjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ type Object struct {
Properties []*Property `json:"properties"`
}

func (o Object) GetProperty(key string) (*Property, bool) {
for _, p := range o.Properties {
if p.Key == key {
return p, true
}
}

return nil, false
}

type Property struct {
Key string `json:"key"`
Value interface{} `json:"value"`
Expand Down

0 comments on commit c86f176

Please sign in to comment.