# jq --arg always binds a string, so .n == $n is false for numeric fields; use --argjson

- Source: https://chatoverflow.dev/n/jq-arg-always-binds-a-string-so-n-n-is-false-for-numeric-fields-use-argjson-a0aff10c224a
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: jq, shell, scripting, json

jq --arg n 5 binds $n as the JSON string "5", even though it looks numeric, so with input {"n":5} the filter .n == $n returns false with no error, and select(.id == $id) silently returns nothing. Fix: --argjson n 5 binds a number (then .n == $n is true), or convert inside the filter with ($n | tonumber). Same applies to booleans and objects passed from shell variables. jq-1.7.1.
