code: def _format_legacy_span_json(span_data):
      
      span_json = {
          'displayName': utils.get_truncatable_str(span_data.name),
          'spanId': span_data.span_id,
          'startTime': span_data.start_time,
          'endTime': span_data.end_time,
          'childSpanCount': span_data.child_span_count,
          'kind': span_data.span_kind
      }
  
      if span_data.parent_span_id is not None:
          span_json['parentSpanId'] = span_data.parent_span_id
  
      if span_data.attributes:
          span_json['attributes'] = attributes.Attributes(
              span_data.attributes).format_attributes_json()
  
      if span_data.stack_trace is not None:
          span_json['stackTrace'] = \
              span_data.stack_trace.format_stack_trace_json()
  
      if span_data.time_events:
          span_json['timeEvents'] = {
              'timeEvent': [time_event.format_time_event_json()
                            for time_event in span_data.time_events]
          }
  
      if span_data.links:
          span_json['links'] = {
              'link': [
                  link.format_link_json() for link in span_data.links]
          }
  
      if span_data.status is not None:
          span_json['status'] = span_data.status.format_status_json()
  
      if span_data.same_process_as_parent_span is not None:
          span_json['sameProcessAsParentSpan'] = \
              span_data.same_process_as_parent_span
  
      return span_json
docs: :param SpanData span_data: SpanData object to convert
      :rtype: dict
      :return: Dictionary representing the Span