Fix integer handling when encoding configuration

This PR fixes #1812.  Includes API tests and integration tests for the regression.
You're right, fixing.  Who'd use an integer as a key though!?