Skip to content

Commit

Permalink
✨ Feat(#4) :: Song 객체를 JSON으로 변환 함수 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
mic050r committed Jan 29, 2025
1 parent 2812b57 commit 52696e0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/models/song.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Song {

Song({required this.title, required this.singer, required this.tjNumber, required this.kyNumber, required this.img});

// JSON에서 Song 객체로 변환
factory Song.fromJson(Map<String, dynamic> json) {
return Song(
title: json['title'] ?? '',
Expand All @@ -17,4 +18,15 @@ class Song {
img: json['img'] ?? '',
);
}

// Song 객체를 JSON으로 변환
Map<String, dynamic> toJson() {
return {
'title': title,
'singer': singer,
'tj_number': tjNumber,
'ky_number': kyNumber,
'img': img,
};
}
}

0 comments on commit 52696e0

Please sign in to comment.