Repository navigation
Replies: 1 comment
|
Use jq 'with_entries(select(.key | length == 11))' input.jsonWhat this does:
Example: $ jq 'with_entries(select(.key | length == 11))' <<'JSON'
{
"18003432343": 1,
"18005553332": 2,
"1-3-2025 10:36:41_08941100 AM": 3
}
JSON{
"18003432343": 1,
"18005553332": 2
}If you only care about digit keys of length 11, tighten the filter: jq 'with_entries(select(.key | test("^[0-9]{11}$")))' input.json |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have JSON that looks like:
I would like to use JQ to filter out all keys where the key length does not equal to 11. So for the above input, the output should be:
What is the appropriate JQ command line for this?
All reactions