[英]Reference to root element as key in JSON Path Expression
I have a JSON like this我有一个这样的 JSON
{
"a" : 1,
"key_to_find" : "value_of_key",
"nested" : {
"value_of_key" : "real_value",
"b" : 2
}
}
I want to create a JSON Path expression to get "real_value", but I don't now the key "value_of_key" so I need to dynamically reference it.我想创建一个 JSON 路径表达式来获取“real_value”,但我现在没有键“value_of_key”,所以我需要动态引用它。 I tried something like:我试过类似的东西:
$.nested['$.key_to_find'] $.nested['$.key_to_find']
but it doesn't work.但它不起作用。 How can I reference to root element value as key to get children values?如何引用根元素值作为获取子值的键? Is that possible?那可能吗?
I need to use it inside AWS Step Functions, so no programming languages/libraries can be used.我需要在 AWS Step Functions 中使用它,因此无法使用任何编程语言/库。
References like this aren't part of JSON Path, though I think since you're using them inside AWS, you'll need to see exactly what they support.像这样的引用不是 JSON 路径的一部分,但我认为既然您在 AWS 中使用它们,您将需要确切地了解它们支持的内容。 It varies.它各不相同。 Widely.广泛。
We (the team working on the coming specification ) have looked at the idea of a key()
or index()
function, however.然而,我们(制定即将到来的规范的团队)已经研究了key()
或index()
function 的想法。 You may find this discussion enlightening as well.您可能会发现此讨论也很有启发性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.