This is an alternative approach to #15448 and also tries to eliminate “Error parsing JSON” errors. This came up in connection with getblockstats
in this comment again: #19885 (comment) and that lead me to look into it.
Conceptually I am not completely against the approach of #15448 but it stalled and maybe this approach is favored by reviewers.