As the comment for the function states, this is behavior for JSON.stringify so we need to do it this way.