# Your Second Flutter App, Episode 8: Parse Domains | raywenderlich.com

**URL:** <https://forums.kodeco.com/t/your-second-flutter-app-episode-8-parse-domains-raywenderlich-com/161811>\
**Category:** 🎓 Courses & Articles\
**Created:** [January 10, 2022, 8:23pm UTC](https://forums.kodeco.com/t/your-second-flutter-app-episode-8-parse-domains-raywenderlich-com/161811 "2022-01-10T20:23:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [January 10, 2022, 8:23pm UTC](https://forums.kodeco.com/t/your-second-flutter-app-episode-8-parse-domains-raywenderlich-com/161811/1 "2022-01-10T20:23:36Z")

</div>

See how to parse more complicated data returned from the API, a list of domains associated with each course.

* * *
This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/25841733-your-second-flutter-app/lessons/8](https://www.raywenderlich.com/25841733-your-second-flutter-app/lessons/8)

---

<div class="post-metadata">

**Author:** ![ncase01](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ncase01/32/102075_2.png) [@ncase01](https://forums.kodeco.com/u/ncase01)\
**Post date:** [June 7, 2022, 3:13pm UTC](https://forums.kodeco.com/t/your-second-flutter-app-episode-8-parse-domains-raywenderlich-com/161811/2 "2022-06-07T15:13:21Z")

</div>

When I run the app I get the following:

```auto
Exception has occurred.

NoSuchMethodError (NoSuchMethodError: Class 'Domain' has no instance method '[]'. Receiver: Instance of 'Domain' Tried calling: []("id"))

```

So, I changed the code to:

course.dart

```auto
Course.fromJson(Map<String, dynamic> json)
      : courseId = json['id'] as String,
        name = json['attributes']['name'] as String,
        description = json['attributes']['description_plain_text'] as String,
        artworkUrl = json['attributes']['card_artwork_url'] as String,
        difficulty = json['attributes']['difficulty'] as String,
        contributors = json['attributes']['contributor_string'] as String,
        domains = List.from(json['relationships']['domains']['data'])
            .map((e) => Domain.fromJson(Map.from(e)))
            .toList();

```

Looks like the API response has changed. The type field is always “domains”, so I ended up using the id field to figure out the name.

domain.dart

```auto
class Domain {
  final String id;
  final String type;

  Domain(this.id, this.type);

  Domain.fromJson(Map<String, String> json)
      : id = json['id'] as String,
        type = json['type'] as String;

  String get name {
    switch (id) {
      case Constants.iosDomain:
        return Strings.ios;
      case Constants.androidDomain:
        return Strings.android;
      case Constants.flutterDomain:
        return Strings.flutter;
      case Constants.sssDomain:
        return Strings.sss;
      case Constants.unityDomain:
        return Strings.unity;
      case Constants.macosDomain:
        return Strings.macos;
      case Constants.archivedDomain:
        return Strings.archived;
      default:
        return Strings.unknown;
    }
  }
}

```
