I'm using jq to find patterns in a very large JSON file (500MB+) with the following flat object structure:
{
"prop1": "large string",
"prop2": "another large string",
"prop3": "yet another large string",
...
}
The below query works fine and it takes less than 15sec to return results:
jq 'map(select(contains("PATTERN")==true))' largefile.json > res.json
but that returns me an array of the strings in which the pattern is found, so I lose the property names. When I try to use map_values, so I can also get the property names, as in:
jq 'map_values(select(contains("PATTERN")==true))' largefile.json > res.json
the query takes forever.
Is there an equivalent query that is fast like map, and which can also provide me with the key:value pairs?