fix toJson on null or undefined values