asJson method

Map<String, dynamic>? asJson()

Returns the parameters as a deeply structured JSON object (the lists contained within will be expanded).

Includes the GemParameter.key, GemParameter.value, and, if available, GemParameter.name. The GemParameter.value is formatted according to its GemParameter.type.

Returns null if GemParameter.key, GemParameter.value, or GemParameter.type are null.

Implementation

Map<String, dynamic>? asJson() {
  if (type == null || value == null || key == null) return null;
  if (type == ValueType.invalid) return null;

  return {
    'key': key!,
    if (name != null) 'name': name,
    'value': value is! ParameterList ? value : value.asJson(),
  };
}