force encoding undefined as json null