Csv wird korrekt Header formatiert (JsonProperty Fehler)
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AICore.Context.SummaryParser
|
||||
@@ -83,7 +84,10 @@ namespace AICore.Context.SummaryParser
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(delimiter);
|
||||
sb.Append(EscapeCsvField(properties[i].Name));
|
||||
|
||||
// Header formatieren
|
||||
var name = GetJsonPropertyName(properties[i]);
|
||||
sb.Append(EscapeCsvField(name));
|
||||
}
|
||||
sb.AppendLine();
|
||||
}
|
||||
@@ -131,5 +135,16 @@ namespace AICore.Context.SummaryParser
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
string GetJsonPropertyName(PropertyInfo propertyInfo)
|
||||
{
|
||||
var jsonPropertyAttribute = propertyInfo.GetCustomAttribute<JsonPropertyNameAttribute>();
|
||||
if (jsonPropertyAttribute != null)
|
||||
{
|
||||
return jsonPropertyAttribute.Name;
|
||||
}
|
||||
|
||||
return propertyInfo.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user