2023-11-30 12:01:20 +01:00
|
|
|
# jsonsearch
|
|
|
|
Very simple tool to search by string or number value and get the JSON key from it.
|
|
|
|
|
|
|
|
## Usage
|
2023-11-30 12:05:16 +01:00
|
|
|
`jsonsearch [-all] [-type=(string|number)] <match> [<file>|-]`
|
|
|
|
|
|
|
|
- `-all` will search for all occurrences
|
|
|
|
- `-type` will set the type to search for; defaults to string
|
|
|
|
- `<match>` is the value to match against
|
|
|
|
- `<file>|-` is either a relative file path or a dash, indicating to read from STDIN.
|
|
|
|
|
2023-11-30 12:01:20 +01:00
|
|
|
```sh
|
|
|
|
# Search for the first occurrence of 'foo Bar'.
|
|
|
|
jsonsearch "foo Bar" myfile.json
|
|
|
|
|
|
|
|
# Search for all occurrences of 'foo Bar'.
|
|
|
|
jsonsearch -all "foo Bar" myfile.json
|
|
|
|
|
|
|
|
# Search using STDIN
|
|
|
|
cat myfile.json | jsonsearch "foo Bar"
|
|
|
|
# or
|
|
|
|
cat myfile.json | jsonsearch "foo Bar" -
|
|
|
|
|
|
|
|
# Search a number
|
|
|
|
jsonsearch -type=number 3.141518 myfile.json
|
|
|
|
```
|