How to append value to json key using?
val=""text"",""text"",""text""
jq '.doc[1].DEF[3].value="update comma separated val here" <<< "$jsonStr"
If your goal is to split a string on commas to generate a list, and use your list in jq, that might look like:
val=text1,text2,text3
jq --arg val "$val" '.whatever.item |= ($val | split(","))' <<<'{"whatever": {}}'
Note:
jq argument --arg is used to pass that variable from a shell context to a jq context.|= construct is used to modify a nested value while still evaluating to the larger document.
val=text,text,text; the quotes do nothing whatsoever (they don't become part of the shell variable's value, because they're parsed as syntax). You can verify this withecho "$val".