MCPcopy
hub / github.com/BishopFox/jsluice / AsMap

Method AsMap

tree.go:256–276  ·  view source on GitHub ↗

AsMap returns a representation of the Node as a map[string]any

()

Source from the content-addressed store, hash-verified

254
255// AsMap returns a representation of the Node as a map[string]any
256func (n *Node) AsMap() map[string]any {
257 if n.Type() != "object" {
258 return map[string]any{}
259 }
260
261 pairs := n.NamedChildren()
262
263 out := make(map[string]any, len(pairs))
264
265 for _, pair := range pairs {
266 if pair.Type() != "pair" {
267 continue
268 }
269
270 key := DecodeString(pair.ChildByFieldName("key").RawString())
271 value := pair.ChildByFieldName("value").AsGoType()
272
273 out[key] = value
274 }
275 return out
276}
277
278// AsArray returns a representation of the Node as a []any
279func (n *Node) AsArray() []any {

Callers 12

AsGoTypeMethod · 0.95
awsMatcherFunction · 0.45
objectMatcherMethod · 0.45
pairMatcherMethod · 0.45
stringMatcherMethod · 0.45
matchJQueryFunction · 0.45
AllSecretMatchersFunction · 0.45
AllURLMatchersFunction · 0.45
githubKeyMatcherFunction · 0.45
gcpKeyMatcherFunction · 0.45
firebaseMatcherFunction · 0.45
mainFunction · 0.45

Calls 6

TypeMethod · 0.95
NamedChildrenMethod · 0.95
DecodeStringFunction · 0.85
RawStringMethod · 0.80
ChildByFieldNameMethod · 0.80
AsGoTypeMethod · 0.80

Tested by

no test coverage detected