[Cialug] JSON Question

Todd Walton tdwalton at gmail.com
Mon Oct 7 12:38:02 UTC 2019


On Fri, Oct 4, 2019 at 3:00 PM Jeffrey Ollie <jeff at ocjtech.us> wrote:

> I think that to_entries will do what you need:
>
> jq '.tasks[0].hosts | to_entries | map({host: .key, failed:
> .value.failed})' test-data.json
> [
>   {
>     "host": "hostone.example.com",
>     "failed": false
>   },
>   {
>     "host": "hosttwo.example.com",
>     "failed": true
>   }
> ]
>

K.O. by J.O.! to_entries ftw. Thank you.

--
Todd


More information about the Cialug mailing list