Skip to content

invert

invert(object) → object · Object

Invert an object by swapping keys and values. Values become keys and keys become values.

  • object (required): object to invert
bash
echo '{"US": "United States", "GB": "United Kingdom"}' | utlx -e 'invert($input)'
# {"United States": "US", "United Kingdom": "GB"}
utlx
{
  countryByName: invert($input.codeToName)
}

Released under AGPL-3.0.