OutputDescriptor.fromJson constructor

OutputDescriptor.fromJson(
  1. dynamic jsonObject
)

Implementation

OutputDescriptor.fromJson(dynamic jsonObject) {
  var map = credentialToMap(jsonObject);
  if (map.containsKey('id')) {
    id = map['id'];
  } else {
    throw Exception('id property needed in output descriptor');
  }
  if (map.containsKey('schema')) {
    schema = map['schema'];
  } else {
    throw Exception('schema property needed in output descriptor');
  }
  name = map['name'];
  description = map['description'];
  if (map.containsKey('styles')) {
    var stylesObject = map['styles'];
    if (stylesObject is String) {
      styles = stylesObject;
    } else if (stylesObject is Map) {
      styles = EntityStyles.fromJson(stylesObject);
    } else {
      throw Exception('unknown datatype for styles Property');
    }
  }

  if (map.containsKey('display')) {
    display = DisplayProperty.fromJson(map['display']);
  }
}