appendToJsonObject method

Map<String, dynamic> appendToJsonObject(
  1. Map<String, dynamic> jsonObject
)

Serializes a map of PublicationCollection indexed by their role into a RWPM JSON representation and add them to the given jsonObject.

Implementation

Map<String, dynamic> appendToJsonObject(Map<String, dynamic> jsonObject) =>
    jsonObject.also((it) {
      for (MapEntry<String, List<PublicationCollection>> entry in entries) {
        String role = entry.key;
        List<PublicationCollection> collections = entry.value;
        if (collections.length == 1) {
          it.putJSONableIfNotEmpty(role, collections.first);
        } else {
          it.putIterableIfNotEmpty(role, collections);
        }
      }
    });