Serialise to the wire format.
Map<String, Object?> toJson() => <String, Object?>{ 'index': index, 'built': built, 'routeType': routeType, 'stack': stack.toJson(), };