如何保留一个对象级别并仅提取其子项之一? [英] How to keep one level of object and extract one of its sub-key only?
本文介绍了如何保留一个对象级别并仅提取其子项之一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用terraform状态json输出播放内容,并想对其进行一些转换.
I'm playing a bit with terraform state json output and want to transform it a bit.
给出从terraform发出的输入:
Given that input issued from terraform:
{
"cost": {
"sensitive": false,
"value": "123"
},
"test_id": {
"sensitive": false,
"value": "6610758455459338306"
}
}
如何将其转换为对以下应用程序有用的东西:
How do i convert it to something usefull for my application like bellow:
{
"cost": "123",
"test_id": "6610758455459338306"
}
我试图和from_entries
,with_entries
一起玩,但是我对它完全陌生了
I tried to play with from_entries
, with_entries
but i'm a complete noob at it
推荐答案
You're looking for map_values
. It works just like map
, but doesn't convert an object input to an array.
map_values(.value)
这篇关于如何保留一个对象级别并仅提取其子项之一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文