jsonifyStruct function
Implementation
Map<String, dynamic> jsonifyStruct(HTStruct struct, {HTStruct? from}) {
final output = <String, dynamic>{};
for (final key in struct.keys) {
if (from != null && from.containsKey(key)) continue;
var value = struct[key];
// ignore none json data value
if (isJsonDataType(value)) {
if (value is Iterable) {
value = jsonifyList(value);
} else if (value is HTStruct) {
value = jsonifyStruct(value);
}
output[key] = value;
}
}
// print prototype members, ignore the root object members
if (struct.prototype != null && !struct.prototype!.isRootPrototype) {
final inherits = jsonifyStruct(struct.prototype!, from: from ?? struct);
output.addAll(inherits);
}
return output;
}