toJson method

  1. @override
Map<String, dynamic> toJson()
override

Converts this body temperature measurement to its JSON representation.

Returns a map with the following keys:

  • 'body_temperature': The temperature value and unit
  • 'effective_time_frame': When the measurement was taken
  • 'descriptive_statistic': Optional statistical context (if provided)
  • 'measurement_location': Optional anatomical location (if provided)
  • 'temporal_relationship_to_sleep': Optional relationship to sleep (if provided)

Implementation

@override
Map<String, dynamic> toJson() {
  final Map<String, dynamic> data = {
    'body_temperature': bodyTemperature.toJson(),
    'effective_time_frame': effectiveTimeFrame.toJson(),
  };
  if (descriptiveStatistic != null) {
    data['descriptive_statistic'] = descriptiveStatistic!.toJson();
  }
  if (measurementLocation != null) {
    data['measurement_location'] = measurementLocation!.toJson();
  }
  if (temporalRelationshipToSleep != null) {
    data['temporal_relationship_to_sleep'] =
        temporalRelationshipToSleep!.toJson();
  }
  return data;
}