jq is a lightweight and flexible command-line JSON processor.
The examples that I'm placing here are to help remind me how to do some parsing.
echo -e '["foo","bar"]\n["foo","fizz","buzz"]' | jq -c -s 'map(.[])'
Flatten with filtering then unique.
echo '{"request":"hello","query":{"foo":"bar","hello":"there"}}
{"request":"bye","query":{"not":"nogood"}}
{"request":"hello"}
{"request":"hello","query":{"foo":"bar","fizz":"buzz"}}' | \
jq -c -s 'map(select(.request=="hello" and .query) | .query | keys) | map(.[]) | unique'