Fix Json.writes[X] so that it works with non-local names too. Issue #2903.
Merge pull request #2928 from darabos/json-macros-for-non-local-names-squashed

Fix Json.writes[X] so that it works with non-local names too. Issue #2903.