From c86f17689e92215cf5c9a77e9a05b5c8b95210fb Mon Sep 17 00:00:00 2001 From: nikitaksv Date: Mon, 8 Feb 2021 03:16:23 +0300 Subject: [PATCH] Added method GetProperty for Object struct --- dynjson.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dynjson.go b/dynjson.go index f4b7cb5..8b1677f 100644 --- a/dynjson.go +++ b/dynjson.go @@ -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"`