cast json values on write to be consistent with reading from the db.

See also commit 5ac2341fab689344991b2a4817bd2bc8b3edac9d
Make remote_ip detection properly handle private IPv6 addresses

Fixes #12638.