ResourceContent.fromJson constructor

ResourceContent.fromJson(
  1. Map<String, dynamic> json
)

Reads an embedded resource content block; the flat form 2.x also read ({"type": "resource", "uri": …, "text": …}) is nested as the specification has it.

Implementation

ResourceContent.fromJson(Map<String, dynamic> json)
    : _block = EmbeddedResource.fromJson(json['resource'] is Map
          ? Map<String, Object?>.from(json)
          : {
              'type': 'resource',
              'resource': {
                for (final k in const ['uri', 'mimeType', 'text', 'blob', '_meta'])
                  if (json.containsKey(k)) k: json[k],
              },
              if (json.containsKey('annotations')) 'annotations': json['annotations'],
            });