add toJson() method to Record and Collection

closes #7