Safely get a nested property value from an object.
Code
Generalecho "$obj" | jq -r ".${path//./\".\"}" 2>/dev/null || echo "null"Parameters
JSON object
Dot-separated path to property
Server
More Bash Snippets
Deep Clone Object
Create a deep copy of an object (handles nested objects and arrays).
Is Empty Object
Check if an object has no properties.
Merge Objects
Merge two objects together (shallow merge).
Array Difference
Find elements in the first array that are not present in the second array.
Array Frequencies
Count how many times each value appears in an array and return a frequency map.
Array Head
Get the first n elements of an array.