func()

in azureappconfiguration/internal/tree/tree.go [55:86]


func (t *Tree) Unflatten() any {
	if len(t.children) == 0 {
		return t.value
	}

	isArray := true
	childrenArray := make([]*Tree, len(t.children))

	for k, v := range t.children {
		idx, err := strconv.Atoi(k)
		if err != nil || idx >= len(t.children) || idx < 0 {
			isArray = false
			break
		}
		childrenArray[idx] = v
	}

	if isArray {
		result := make([]any, len(childrenArray))
		for i, child := range childrenArray {
			result[i] = child.Unflatten()
		}
		return result
	}

	result := make(map[string]any)
	for k, child := range t.children {
		result[k] = child.Unflatten()
	}

	return result
}