eolas/neuron/9445c5fd-135c-4b0b-a70c-7a6fd45d9d58/jq.md

36 lines
515 B
Markdown
Raw Normal View History

2024-12-09 18:34:15 +00:00
---
tags:
- json
- shell
---
# 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))`