json stringify of undefined does not work as expected