CockpitSnapshotTarget.fromJson constructor

CockpitSnapshotTarget.fromJson(
  1. Map<String, Object?> json
)

Decodes a CockpitSnapshotTarget from a JSON object.

Implementation

factory CockpitSnapshotTarget.fromJson(Map<String, Object?> json) {
  final layoutJson = json['layout'] as Map<Object?, Object?>?;
  final contentJson = json['content'] as Map<Object?, Object?>?;
  final styleJson = json['style'] as Map<Object?, Object?>?;
  return CockpitSnapshotTarget(
    registrationId: json['registrationId']! as String,
    cockpitId: json['cockpitId'] as String?,
    semanticId: json['semanticId'] as String?,
    keyValue: json['keyValue'] as String?,
    text: json['text'] as String?,
    tooltip: json['tooltip'] as String?,
    typeName: json['typeName'] as String?,
    path: json['path'] as String?,
    scrollablePath: json['scrollablePath'] as String?,
    scrollableKeyValue: json['scrollableKeyValue'] as String?,
    scrollableTypeName: json['scrollableTypeName'] as String?,
    routeName: json['routeName']! as String,
    supportedCommands:
        (json['supportedCommands'] as List<Object?>? ?? const <Object?>[])
            .map(CockpitCommandType.fromJson)
            .toList(growable: false),
    layout: layoutJson == null
        ? null
        : CockpitSnapshotLayout.fromJson(
            Map<String, Object?>.from(layoutJson),
          ),
    content: contentJson == null
        ? null
        : CockpitSnapshotContent.fromJson(
            Map<String, Object?>.from(contentJson),
          ),
    style: styleJson == null
        ? null
        : CockpitSnapshotStyle.fromJson(Map<String, Object?>.from(styleJson)),
    ancestors: (json['ancestors'] as List<Object?>? ?? const <Object?>[])
        .cast<Map<Object?, Object?>>()
        .map(
          (item) => CockpitSnapshotAncestor.fromJson(
            Map<String, Object?>.from(item),
          ),
        )
        .toList(growable: false),
    diagnosticProperties:
        (json['diagnosticProperties'] as List<Object?>? ?? const <Object?>[])
            .cast<Map<Object?, Object?>>()
            .map(
              (item) => CockpitDiagnosticProperty.fromJson(
                Map<String, Object?>.from(item),
              ),
            )
            .toList(growable: false),
  );
}