json - JQ 横向列表作为地图
问题描述
我想将下面的 JSON 转换为 Map。但它以列表的形式出现。
{
"_embedded": {
"items": [
{
"order": 1,
"technical": {
"id": 1,
"_links": {
"self": {
"href": "/profile/api/v3/service/40/technical"
}
}
}
},
{
"order": 2,
"technical": {
"id": 1,
"_links": {
"self": {
"href": "/profile/api/v3/service/40/technical"
}
}
}
}
]
}
}
预期格式:
{
"1": "/profile/api/v3/service/40/technical",
"2": "/profile/api/v3/service/40/technical"
}
但我得到:::
[
{
"1": "/profile/api/v3/service/40/technical"
},
{
"2": "/profile/api/v3/service/40/technical"
}
]
JQ查询:::
._embedded.items | map({(.order| tostring ) : .technical._links.self.href} )
请帮助,在此先感谢..
解决方案
只需| add
添加到 jq 程序的末尾即可。
推荐阅读
- php - Zend 服务器 - 启用 Windows 身份验证 / NTLM / Apache mod_authnz_sspi
- mongodb - 构建一个mongo容器并导入数据
- verilog - 如何在 FPGA 的 PMOD 键盘上保存按键条目
- javascript - 数据表:单击按钮不打开视图
- windows - 如何在 Windows 中以特定顺序连接多个降价文件
- karate - 如何在空手道框架功能文件中的 POST/GET 请求中将 apikey 作为授权传递
- shopify - Shopify 禁用渠道中的产品(发布评估)
- javascript - 如何使 pdf.js 库在 Internet Explorer 中工作
- amazon-web-services - 无法连接到可公开访问的 AWS RDS
- excel - 根据单元格值定义起始范围