Work in progress: generic function to spawn a subprocess and collect/parse its (JSON) output.