RunCommand: move JSON generation to its own function

Created by  Graham Christensen  on December 8, 2021
354QHWZ7XFIDL4YLGMJB6TTCZDXIU2NJG2JXMYNXTQKEHM5VQOOAC
Change contents