toJSON implementation for node object