jq is usually for JSON going in. With -R (raw input) it reads plain text instead, one string per line, which makes it a handy tool for turning text into JSON.
printf 'alpha\nbeta\n\ngamma\n' | jq -nR '[inputs | select(length > 0)]'
# ["alpha", "beta", "gamma"]
cut -d: -f1,7 /etc/passwd | jq -R 'split(":") | {user: .[0], shell: .[1]}'
Each line arrives as a JSON string without its newline. In the first command, -n plus inputs collects all lines into one array, and select(length > 0) drops the empty one. The second turns the user names and login shells from /etc/passwd into objects, ready to be filtered further or sent to an API.
I like this pattern for building a JSON array from a list of host names or file names, since doing that with echo and quotes is asking for broken output the first time a name has a quote in it. jq escapes everything properly.
One gotcha: -R combined with -s doesn’t give you an array of lines. It gives you the whole input as one long string, newlines included, and you have to split it yourself with split("\n"), which leaves an empty string at the end. The -n and inputs version avoids that.
Further reading: jq manual: invoking jq (–raw-input), jq manual: inputs