`jq` can construct JSON "safely" from shell constructs, but is rather more verbose - e.g. with the same examples:
$ jq -n --arg name Jane '{"name":$name}' $ jq -n \ --argjson time $(date +%s) \ --arg dir $HOME \ '{"time":$time,"dir":$dir}' $ jq -n '$ARGS.positional' --args spring summer winter $ jq -n \ --arg name JP \ --argjson object "$( jq -n \ --arg fruit Orange \ --argjson point "$( jq -n \ --argjson x 10 \ --argjson y 20 \ '{"x":$x,"y":$y}' \ )" \ --argjson number 17 \ '{"fruit":$fruit,"point":$point,"number":$number}' \ )" \ --argjson sunday false \ '{"name":$name,"object":$object,"sunday":$sunday}'
`jq` can construct JSON "safely" from shell constructs, but is rather more verbose - e.g. with the same examples: