update toJSON method and add native support