MCPcopy
hub / github.com/TomWright/dasel / MapKeyValues

Method MapKeyValues

model/value_map.go:210–230  ·  view source on GitHub ↗

MapKeyValues returns a list of key value pairs in the map.

()

Source from the content-addressed store, hash-verified

208
209// MapKeyValues returns a list of key value pairs in the map.
210func (v *Value) MapKeyValues() ([]KeyValue, error) {
211 keys, err := v.MapKeys()
212 if err != nil {
213 return nil, fmt.Errorf("error getting map keys: %w", err)
214 }
215
216 kvs := make([]KeyValue, len(keys))
217
218 for i, k := range keys {
219 va, err := v.GetMapKey(k)
220 if err != nil {
221 return nil, fmt.Errorf("error getting map key: %w", err)
222 }
223 kvs[i] = KeyValue{
224 Key: k,
225 Value: va,
226 }
227 }
228
229 return kvs, nil
230}
231
232// MapLen returns the length of the slice.
233func (v *Value) MapLen() (int, error) {

Callers 10

TestMapKeyValuesFunction · 0.95
MapCopyMethod · 0.95
mapToNodesFunction · 0.80
modelValueToNodeFunction · 0.80
buildGoValueForMapFunction · 0.80
goTypeAndValueFunction · 0.80
toElementMethod · 0.80
addValueToBodyMethod · 0.80
writeMapMethod · 0.80
deepMergeMapFunction · 0.80

Calls 2

MapKeysMethod · 0.95
GetMapKeyMethod · 0.95

Tested by 1

TestMapKeyValuesFunction · 0.76