private GenericRecord CreateAvroRecord(string json, string avroSchema)
{
try
{
var schema = (RecordSchema)Schema.Parse(avroSchema);
var jsonObject = jsonSerializer.Deserialize <JsonObject>(json);
var result = (GenericRecord)GetValue(jsonObject, schema);
return(result);
}
catch (JsonException ex)
{
throw new InvalidOperationException($"Failed to parse json: {json}, got {ex.Message}", ex);
}
}