GetKeys returns a slice of all keys in an object
()
| 83 | |
| 84 | // GetKeys returns a slice of all keys in an object |
| 85 | func (o Object) GetKeys() []string { |
| 86 | out := make([]string, 0) |
| 87 | if !o.HasValidNode() { |
| 88 | return out |
| 89 | } |
| 90 | |
| 91 | count := int(o.node.NamedChildCount()) |
| 92 | |
| 93 | for i := 0; i < count; i++ { |
| 94 | pair := o.node.NamedChild(i) |
| 95 | |
| 96 | if pair.Type() != "pair" { |
| 97 | continue |
| 98 | } |
| 99 | |
| 100 | key := pair.ChildByFieldName("key").RawString() |
| 101 | out = append(out, key) |
| 102 | } |
| 103 | return out |
| 104 | } |
| 105 | |
| 106 | // GetObject returns the property corresponding to the |
| 107 | // provided key as an Object |
no test coverage detected