closes #12967 fix [en|de]coding of HashMap<K,V> where K is a numeric type

Details are in #12967.

This is just w/i the `serialize::json` module. If you have feedback for how to improve this impl, I'm all ears. This is to work around a blocking issue I've encountered with an application I'm working on.