use custom encoder for JSON model #331