Removed incorrect handling ```toJSON()``` for empty collections