[json-rpc] Fix display stackoverflow and add unit test
[json-rpc] Fix display stackoverflow and add unit test

Closes: #5218
Approved by: andll

aptos-labs/aptos-core,aptos-labs/aptos-core,libra/libra,aptos-labs/aptos-core,aptos-labs/aptos-core,aptos-labs/aptos-core,aptos-labs/aptos-core,libra/libra,aptos-labs/aptos-core,libra/libra,libra/libra,libra/libra