parseTelemetry function
Parse the raw telemetry JSON string (array of metrics) into typed values. Returns an empty list for null, a parse error, or a non-array payload.
Implementation
List<SyniInferenceMetric> parseTelemetry(String? json) {
if (json == null || json.isEmpty) return const [];
final dynamic decoded;
try {
decoded = jsonDecode(json);
} on FormatException {
return const [];
}
if (decoded is! List) return const [];
return decoded
.whereType<Map>()
.map((m) => SyniInferenceMetric.fromMap(m.cast<String, dynamic>()))
.toList();
}