Unique by Property

Remove duplicates from array of objects by a specific property.

Code

General
echo "$arr" | jq --arg k "$key" 'unique_by(.[$k])'

Parameters

JSON array of objects

Property to check for uniqueness

Server

More Bash Snippets