Omitting null values for sub() in JQ
You were close. To retain the original structure, you need to use the update operator (|=
) instead of pipe. Enclosing the entire expression to the left of it in parentheses is also necessary, otherwise the original input will be invisible to |=
.
(.results[].suites[].tests[].context | strings) |= sub("#"; "%23")