Skip to content
Discussion options

You must be logged in to vote

Something like this perhaps:

import "strings"

input: {
    another: {
        example: "sure"
    }
}

index: "another.example"

_splitIndex: strings.Split(index, ".")
_resolvedValues: [for i, v in _splitIndex { [if i==0 {input}, _resolvedValues[i-1]][0][_splitIndex[i]] }]

output: _resolvedValues[len(_resolvedValues)-1]

gives:

input: {
	another: {
		example: "sure"
	}
}
index:  "another.example"
output: "sure"

https://tip.cuelang.org/play/?id=1NrNflvLB8Z#cue@export@cue

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@milosjost
Comment options

Answer selected by milosjost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants