I'm trying to convert a big one line JSON file to a multiline JSONLINES file. I've tried a bunch of commands and none of them are doing what I expect them to. This is the format of my data (input file: response.json) -
{"_rid":"12345","Documents":[{"id": "id-1", "name": "name-1", "userId": "userid-1", "_rid": "rid-1"},{"id": "id-2", "name": "name-2", "userId": "userid-2", "_rid": "rid-2"},{"id": "id-3", "name": "name-3", "userId": "userid-3", "_rid": "rid-3"},....],"_count":566}I want to get rid of the unnecessary characters and make each record its own line. I want to get rid of the very first "_rid" but not the ones inside of the individual records. My desired output looks like this -
{"id": "id-1", "name": "name-1", "userId": "userid-1", "_rid": "rid-1"}{"id": "id-2", "name": "name-2", "userId": "userid-2", "_rid": "rid-2"}{"id": "id-3", "name": "name-3", "userId": "userid-3", "_rid": "rid-3"}....These are some queries I've tried (I know some of these aren't going to work but I was desperate and tried so many things):
jq --slurp '.' response.json > output.jsonljq -c '.[]' | jq ."Documents" response.json > output.jsonljq '.[] | select("Documents")' response.json > output.jsonljq '.[]' | jq 'select("Documents")' response.json > output.jsonljq --slurp --compact-output 'map([ . ])' response.json > output.jsonlHow do I do this using jq commands? Thanks!