I have the following JSON message. This is a single complete message. There are so many messages like this in a single file. This json message was generated from a unformated json message using jq.
I would like to do some filtering on this. For example, when i search for first_name, mike1, I should get the header and the matching request inside request. Also the matching result inside the Response message. So, the output is expected as follows for the search string mike1.
Basically, i want to filter out unmatched request inside the requests array and unmatched result inside the result array.
Currently, I use the following script to get the formatted json message from the unformatted json message log file.
sed -n "/<SEARCH_STRING>/ s/.*Service - //p" $1/test.log* | jq . > ~/result.log