Update json::Encoder to properly encode maps.

According to extra::serialize, maps where the key and value types
are encodable should also be encodable, but extra::json only handled
maps with string keys.  This updates extra::json to allow for
non-string keys.

Closes #8883 

May also have some effect on #9028