-
Notifications
You must be signed in to change notification settings - Fork 7
feat(builtins): implement jq --arg and --argjson flags #914
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
jq --arg name value and jq --argjson name value are commonly used flags for safely injecting variables into jq filters without shell interpolation. They are the recommended way to pass dynamic values into jq expressions.
Expected behavior
jq --arg name "John" '.greeting = "Hello " + $name' <<< '{}'
# {"greeting": "Hello John"}
jq --argjson count 42 '.total = $count' <<< '{}'
# {"total": 42}
# Multiple args
jq --arg key "name" --arg val "Alice" '.[$key] = $val' <<< '{}'
# {"name": "Alice"}--arg binds a string value, --argjson binds a parsed JSON value.
References
- jq manual: https://jqlang.github.io/jq/manual/#invoking-jq
- Inspired by just-bash #162
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request