Index By Property

Create an object indexed by a property value for fast lookups.

Code

General
echo "$arr" | jq --arg k "$key" 'map({(.[$k] | tostring): .}) | add'

Parameters

Array of objects (JSON)

Property to index by

Server

More Bash Snippets