Commit 6a1a66c180cba5f2d4189e89327de23505c7f4dd attempted to properly render RPC results of the type ANY.
However, the commit is incomplete.
Fix it, by properly rendering all ANY types.
Moreover, a few trivial refactors after #34683 are included here.