|
|
|
Working with JSON in shell typically requires |
|
|
Check if jq is available: |
|
|
Sample JSON for demonstrations: |
|
|
Pretty print JSON: |
|
|
Extract a field: |
|
|
Extract raw value (no quotes): |
|
|
Multiple fields: |
|
|
Nested objects: |
|
|
Arrays: |
|
|
Iterate over array: |
|
|
Array length: |
|
|
Filter array: |
|
|
Map over array: |
|
|
Transform array: |
|
|
Create JSON: |
|
|
Create from variables: |
|
|
Modify JSON: |
|
|
Conditional updates: |
|
|
Sort array: |
|
|
Group and count: |
|
|
Check if key exists: |
|
|
Default values: |
|
|
Type checking: |
|
|
String operations: |
|
|
Arithmetic: |
|
|
Compact output (no pretty print): |
|
|
Read JSON from file: |
|
|
Process multiple JSON objects (jsonl): |
|
|
Error handling: |
|
|
Combine with shell: |
|
|
Loop over JSON array in shell: |
|
|
Build JSON from loop: |
|
|
Convert to/from other formats: |
|