fromJson static method

GuidedNavigationText? fromJson(
  1. dynamic json
)

Parses a GuidedNavigationText from its JSON representation.

Accepts either a String or a Map<String, dynamic> with at least one of plain or ssml.

Implementation

static GuidedNavigationText? fromJson(dynamic json) {
  if (json == null) return null;
  if (json is String) {
    return json.isNotEmpty ? GuidedNavigationTextString(json) : null;
  }
  if (json is Map<String, dynamic>) {
    final jsonObject = Map<String, dynamic>.of(json);
    final plain = jsonObject.optNullableString('plain', remove: true);
    final ssml = jsonObject.optNullableString('ssml', remove: true);
    final language = jsonObject.optNullableString('language', remove: true);
    if (plain == null && ssml == null) return null;
    return GuidedNavigationTextObject(
      plain: plain,
      ssml: ssml,
      language: language,
    );
  }
  return null;
}