From 2e69cb0d7cd22f866ed4e1740c3257f10339a420 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Wed, 14 Feb 2024 15:57:27 +0000 Subject: [PATCH] add notes on jq --- Linux/jq.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Linux/jq.md diff --git a/Linux/jq.md b/Linux/jq.md new file mode 100644 index 0000000..6f98b3d --- /dev/null +++ b/Linux/jq.md @@ -0,0 +1,33 @@ +--- +tags: [new, json] +--- + +# jq + +## Remove property + +Remove property from a JSON array of objects: + +```json +{ + "member_inputs": [ + { + "name": "Thomas", + "input_type": "select" + }, + { + "name": "Martha", + "input_type": "text" + } + ] +} +``` + +```sh +jq '.member_details |= map(del(.input_type))' memberDetails.json +``` + +> Add '-i' to modify the source file directly (in-place) + +> Multiple properties can be deleted simply by chaining, +> e.g.`(del(.input_type, .another_property))`