change default behavior to toJSON2 to handle js functions