"any depth" wildchar
* match only one level key:
*.*.*.*.deepKey
It's nice if there is a "any depth" wildchar **, for example
**.deepKey
**deepKey
@kikyous that should be doable with the @dig modifier, see the Modifiers documentation.
For example with a json of:
{ "something": {
"anything": {
"abcdefg": {
"finally": {
"important": {
"secret": "password"
}
}
}
}
}
}
and a query @dig:secret you get:
["password"]
@volans- thanks for comment.
@dig modifier is an approach, but wildchar is more flexible and intuitive, and modifier can not used in sjson
I make a i18n editor: https://github.com/kikyous/i18nedt, basically it's a wrapper on gjson and sjson. It could be convenient to use "any depth" wildchar to get and update a i18n key, like:
i18nedt src/locales/*.json -k **.submitTip
or
i18nedt src/locales/*.json -k **.homework.submitTip
I see. As far as I know the Path functionality to get the effective path don't work with modifiers (otherwise it could allow to get the Path for it and then use the exact path in the rest of the calls) but I'll leave the authoritative answer to @tidwall.
In order to use @dig or a new **-type path for the purpose of modifying the values (such as with sjson), the positions of the results would need to be mapped. The Path functionality, and Index field in particular work by mapping the result to underlying json document.
Unfortunately, modifiers like@dig create new json documents that are not a subset of the original.
To make it work in the way @kikyous is describing, the indexes of the results of @dig and ** would need to be saved somehow.