JQ map_values example

Transform every value of a JSON object with jq map_values(). Interactive example that reshapes each value while preserving the object keys.

The jq expression

map_values({name, ageYears: .age})

map_values(f) applies f to each value of an object (or array) and returns a structure with the same keys. Unlike map, it preserves the object keys. Here we map over an object keyed by user id and reshape each value, keeping name and renaming age to ageYears.

Input JSON

JQ expression

Run with Ctrl/⌘ Enter

Output

Apply the expression to see its output.