简体   繁体   English

引用根元素作为 JSON 路径表达式中的键

[英]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.

相关问题 如何向 json 文件添加“根元素” - How do I add a 'root element' to a json file JSON 和序列化:对此表达式的引用无效。 从 firebase 获取数据作为 firestore 数据库? - JSON and serialization : lnvalid reference to this expression. fetch data form firebase as firestore database? BigQuery JSON 元素提取 - BigQuery JSON element extraction 无法对根引用执行“uploadBytesResumable”操作,使用子项创建非根引用 - The operation 'uploadBytesResumable' cannot be performed on a root reference, create a non-root reference using child Typescript 从根路径导入不起作用 - Typescript import from root path not working 列出 EFS 中的根目录路径 - List out Root Directory path in EFS Select 使用正则表达式的 SQL 路径中的深度 - Select the depth in SQL path using regex expression 更新嵌套的 bigquery json 元素 - Update nested bigquery json element 用于获取文件路径直到给定斜杠数字的正则表达式 - Regexp expression for getting the file path till a given slash number 将虚拟位置引用为 GCC 中的包含路径 - Reference a virtual location as include path in GCC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM