relationshipToJson function

String relationshipToJson(
  1. Relationship? relationship
)

Converts a Relationship enumeration to a JSON string representation.

This function takes a Relationship enumeration as input and converts it to a JSON string representation. If the input Relationship is null, the function returns the JSON string representation of the default relationship Relationship.unknown. Otherwise, it returns the JSON string representation of the input relationship's name property.

@param relationship The Relationship enumeration to convert to a JSON string. @return A JSON string representation of the input Relationship enumeration.

Implementation

String relationshipToJson(Relationship? relationship) {
  return relationship?.value ?? Relationship.unknown.value;
}