Refactor some helper code in JSON.Encode

This makes it easier to define slightly more efficient helpers.

There is one slight semantics change: `{{"A", "B"}, {"C", "D"}}` won't get
encoded as `{"A": "B", "C", "D"}` but as `[["A", "B"], ["C", "D"]]` because a
tuple now gets treated as a non-keyword list instead of a possibly-keyword list.
Merge pull request #16 from pminten/refactor-encode-helpers

Refactor some helper code in JSON.Encode