2016-09-02 3 views
0

Ich brauche Hilfe dieser JSON AusgabeParser ungewöhnlich JSON Ausgabe im Shell-Skript

Jeder auf Parser-Objekt bringt mir eine Zahl von 0 bis 20, aber jeder Host hat deploy_status vom Host-ID-Nummer nicht vom Objekt zum Parser Zahl, weil diese JSON für mich sehr unterschiedlich ist, ich bin mit Shell-Skript ich habe jq

"meta": { 
    "total_count": 21, 
    "previous": null, 
    "offset": 0, 
    "next": null, 
    "limit": 21 
    } 
} 
"objects": [ 
     { 
     "configuration_id": 61, 
     "deploy_error": "", 
     "deploy_progress": 100, 
     "deploy_status": "deploy_succeeded", 
     "id": 61, 
     "last_reported": "2016-09-02T11:41:37", 
     "last_updated": "2016-09-02T11:21:38", 
     "maintenance_mode": false, 
     "max_audio_calls": 99, 
     "max_full_hd_calls": 4, 
     "max_hd_calls": 8, 
     "max_sd_calls": 18, 
     "media_load": 0, 
     "name": "host1", 
     "resource_uri": "/api/admin/status/v1/worker_vm/61/", 
     "system_location": "Customer-host", 
     "upgrade_status": "IDLE", 
     "version": "12 (29682.0.0)" 
     }, 
     { 
     "configuration_id": 62, 
     "deploy_error": "", 
     "deploy_progress": 100, 
     "deploy_status": "deploy_succeeded", 
     "id": 62, 
     "last_reported": "2016-09-01T16:02:44", 
     "last_updated": null, 
     "maintenance_mode": false, 
     "max_audio_calls": 0, 
     "max_full_hd_calls": 0, 
     "max_hd_calls": 0, 
     "max_sd_calls": 0, 
     "media_load": 0, 
     "name": "host3", 
     "resource_uri": "/api/admin/status/v1/worker_vm/62/", 
     "system_location": "customer-host", 
     "upgrade_status": "IDLE", 
     "version": "11.1 (26965.0.0)" 
     } 
    ] 
+0

'jq ".objects | Karte (wählen (.id == $ id)) |.. [] Deploy_status"' – Phylogenesis

+0

Hallo, das ist groß, aber es war gegeben „Syntaxfehler in der Nähe von unerwartetem Token' wählen '" – Daniel

+0

jq" .objects "| jq "map (select (.id == $ id))" | jq ". []. deploy_status" " Arbeitete als ein Charme Könnten Sie als Antwort für Sie umschreiben, um Punkte zu erzielen? – Daniel

Antwort

0

Der Code unten als Charm funktioniert! Dank Phylogenese.

jq ".objects" | jq "map(select(.id == $id))" | jq ".[].deploy_status"