Inspired by a relay compiler trick, let's implement toJSON to be the same method as toString on type instances.