This example uses the pattern of setting an out=varname when calling a json function, the encoded JSON goes into $varname variable. This pattern avoids the overhead of forking processes (e.g. subshells) when generating JSON.
Otherwise you can use the more normal approach of jb writing to stdout, and capturing the output stream.