Changed if around to match serialize logic with date being inside object branch