Added toObject and toJson method to ModelClass