반응형 fromJson()1 Dart - 직렬화 json_serializable Dart 언어에서는 직렬화를 위해 json_serializable 패키지를 사용할 수 있다고는 하지만, plugin의 Marketplace 에서 Dart Data Class 라는 것을 설치하게 되면 아래와 같이 toJson()/fromJson() 을 쉽게 활용 할 수 있습니다. 조금 황당한 점은 위의 설명에는 함수명이 toJson()/fromJson() 이지만, 실제로 설치하면 아래와 같이 toMap()/fromMap() 으로 나옵니다. (기능은 동일합니다.) class Employee { String name; int age; Employee({ required this.name, required this.age, }); Map toJson() { return { 'name': this.name, 'a.. 2024. 2. 7. 이전 1 다음 728x90 반응형