'jq: find and replace within filter

I return a few json values from an API feed using this command:

curl -s -u user:pass -H 'my header' https://example.com/data.json | jq -cr  '.[] | {id: .id, content: .content, assignee: .assignee.name}

I'm getting a CSV just as I need it, namely:

1235,"some text, sometimes with a comma, perhaps", "John Doe"

Everything is great, but command in the "content: .content" values are throwing off our processing of the data.

I'm trying to replace commas within the command, and not even sure what terminology to search for. Ideally I'd use something like this:

jq -cr  '.[] | {id: .id, content: *** BEGIN DO SOMETHING .content END DO SOMETHING***, assignee: .assignee.name}

...I just don't know what that something is.

I'm guessing it's a gsub, but not sure how to isolate the syntax for .content.

jq


Solution 1:[1]

Should waited the requisite 5 minutes.

Found my answer elsewhere:

jq -cr  '.[] | {id: .id, content: .content | sub(","; ""), assignee: .assignee.name} 

Solution 2:[2]

Yes you can use gsub/2.

Filter

. | gsub(",";"")

Input

1235,"some text, sometimes with a comma, perhaps", "John Doe"

Output

1235"some text sometimes with a comma perhaps" "John Doe"

Demo

https://jqplay.org/s/n5fFtBK7uj

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Creative Arc
Solution 2 Logan Lee