@@ -26,6 +26,15 @@ class ThingDescription {
26
26
/// The [title] of this [ThingDescription] .
27
27
late String title;
28
28
29
+ /// The [description] of this [ThingDescription] .
30
+ String ? description;
31
+
32
+ /// A [Map] of multi-language [titles] .
33
+ final Map <String , String > titles = {};
34
+
35
+ /// A [Map] of multi-language [descriptions] .
36
+ final Map <String , String > descriptions = {};
37
+
29
38
/// The JSON-LD `@context` , represented by a [List] of [ContextEntry] s.
30
39
List <ContextEntry > context = [];
31
40
@@ -81,6 +90,12 @@ class ThingDescription {
81
90
if (base is String ) {
82
91
this .base = base ;
83
92
}
93
+ final dynamic description = json["description" ];
94
+ if (description is String ) {
95
+ this .description = description;
96
+ }
97
+ _parseMultilangString (titles, json, "titles" );
98
+ _parseMultilangString (descriptions, json, "descriptions" );
84
99
final dynamic properties = json["properties" ];
85
100
if (properties is Map <String , dynamic >) {
86
101
_parseProperties (properties);
@@ -103,6 +118,20 @@ class ThingDescription {
103
118
}
104
119
}
105
120
121
+ // TODO(JKRhb): Refactor
122
+ void _parseMultilangString (
123
+ Map <String , String > field, Map <String , dynamic > json, String jsonKey) {
124
+ final dynamic jsonEntries = json[jsonKey];
125
+ if (jsonEntries is Map <String , dynamic >) {
126
+ for (final entry in jsonEntries.entries) {
127
+ final dynamic value = entry.value;
128
+ if (value is String ) {
129
+ field[entry.key] = value;
130
+ }
131
+ }
132
+ }
133
+ }
134
+
106
135
void _parseTitle (dynamic titleJson) {
107
136
if (titleJson is String ) {
108
137
title = titleJson;
0 commit comments