ObjectProperty.fromJson constructor
Creates an ObjectProperty from a JSON Schema fragment.
Implementation
factory ObjectProperty.fromJson(Map<String, dynamic> json) {
List<PropertyNameAndSchema> properties = [];
if (json['properties'] != null &&
json['properties'] is Map<String, dynamic>) {
(json['properties'] as Map<String, dynamic>).forEach(
(key, value) {
properties.add(
PropertyNameAndSchema(
propertyName: key,
schema: TProperty.fromJson(value),
),
);
},
);
}
return ObjectProperty(
properties: properties,
additionalProperties: json['additionalProperties'],
format: json['format'] as String?,
defaultValue: json['default'],
nullable: json['nullable'] ?? false,
enumValues: (json['enum'] as List<dynamic>? ?? [])
.map((e) => e.toString())
.toList(),
);
}