我想通過終端使用終端命令或腳本編輯json的結構。 如果我有這樣一個JSON文件結構:通過命令行向JSON添加一個父屬性
{
"Helloo": [
{
"AlbumTitle": {
"S": "Famous"
},
"SongTitle": {
"S": "Call Me Today"
},
"Artist": {
"S": "No One You Know"
}
},
{
"AlbumTitle": {
"S": "Famous1"
},
"SongTitle": {
"S": "Call Me Today1"
},
"Artist": {
"S": "No One You Know11"
}
}
],
"Music": [
{
"Album": {
"S": "Pop Songs"
},
"Production": {
"S": "X-series"
},
"Song": {
"S": "Once upon
},
"Artist": {
"S": "XYZ"
}
}
]
}
所以在這裏,我想加上「Putrequest」和「項目」屬性的陣列的每一個項目。所以我想輸出是這樣的:
{
"Helloo": [
{
PutRequest":{
"Item":{
"AlbumTitle": {
"S": "Famous"
},
"SongTitle": {
"S": "Call Me Today"
},
"Artist": {
"S": "No One You Know"
}
}
}
},
{
PutRequest":{
"Item":{
"AlbumTitle": {
"S": "Famous1"
},
"SongTitle": {
"S": "Call Me Today1"
},
"Artist": {
"S": "No One You Know11"
}
}
}
}
],
"Music": [
{
PutRequest":{
"Item":{
"Album": {
"S": "Pop Songs"
},
"Production": {
"S": "X-series"
},
"Song": {
"S": "Once upon
},
"Artist": {
"S": "XYZ"
}
}
}
}
]
}
我試圖使用Jq這個,但仍然掙扎..請幫助我使用命令提示符或bash/shell腳本將這些屬性添加到json。 感謝
請告訴我們你已經嘗試過jq。 – cb0
你知道這不是正確的JSON嗎? ''S「:」從前'< - 缺少報價'「' – andlrc