I need to get all values for key “text” in object of objects and arrays. How can I loop through nested multi-level object?
Something like while(is_object($item)) in PHP.
ok, found solution. I can call same partial over if item is slice or map
{{- $output := slice -}}
{{- range $key,$item := . -}}
{{- if (or (reflect.IsSlice $item) (reflect.IsMap $item)) -}}
{{- $output = $output | append (partial "functions/test" $item) -}}
{{- else -}}
{{- if (eq $key "text") -}}
{{- $output = $output | append $item -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $output -}}
Nice. TIL about these reflect
functions