use subtype to disallow encoding invalid values

encode related function should only accept tags that are actually
encodable rather than raising on an invalid json tag.
gitignore