Action.fromJson constructor

Action.fromJson(
  1. Map<String, dynamic> json,
  2. PrefixMapping prefixMapping
)

Creates a new Action from a json object.

Implementation

factory Action.fromJson(
  Map<String, dynamic> json,
  PrefixMapping prefixMapping,
) {
  final Set<String> parsedFields = {};

  final title = json.parseField<String>("title", parsedFields);
  final titles = json.parseMapField<String>("titles", parsedFields);
  final description = json.parseField<String>("description", parsedFields);
  final descriptions =
      json.parseMapField<String>("descriptions", parsedFields);
  final uriVariables = json.parseDataSchemaMapField(
    "uriVariables",
    prefixMapping,
    parsedFields,
  );

  final safe = json.parseField<bool>("safe", parsedFields) ?? false;
  final idempotent =
      json.parseField<bool>("idempotent", parsedFields) ?? false;
  final synchronous = json.parseField<bool>("synchronous", parsedFields);
  final input =
      json.parseDataSchemaField("input", prefixMapping, parsedFields);
  final output =
      json.parseDataSchemaField("output", prefixMapping, parsedFields);

  final forms = json.parseAffordanceForms(prefixMapping, parsedFields);
  final additionalFields =
      json.parseAdditionalFields(prefixMapping, parsedFields);

  final action = Action(
    forms: forms,
    title: title,
    titles: titles,
    description: description,
    descriptions: descriptions,
    uriVariables: uriVariables,
    safe: safe,
    idempotent: idempotent,
    synchronous: synchronous,
    input: input,
    output: output,
    additionalFields: additionalFields,
  );

  return action;
}