Refactor JSON to Stream conversion to a utility.