Using jq streams to strip deeply nested JSON fields
A developer explains how regular jq paths can read deeply nested JSON but cannot easily delete values and write the result back. The tostream and fromstream filters solve this by flattening a document into [path, value] pairs, filtering them, and rebuilding the JSON. One example removes every description key at any depth from an OpenAPI spec using a single command. The author also used the approach to remove x-kubernetes-* extensions from a 2MB Kubernetes CRD in about three seconds, instead of writing a recursive Python script. The article notes trade-offs: key order is lost, the whole document is held in memory, and malformed filtered streams cause errors.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in