changed toJson to return array.