Fixed the 'toJson' method to actually filter keys.