Closed vijaymandave closed 2 years ago
Hi @vijaymandave, ksqlDB.RestApi.Client uses System.Text.Json to deserialize (materialize) the incoming values and it doesn't support collection properties without a setter.
In this case the important part is that RepeatedField<T>
refers to ICollection<T>
:
public interface ICollection<T> : IEnumerable<T>
{
void Add(T item);
//..
}
Would it be a viable option for you to register/plugin a custom JSON converter into KSqlDbProvider?
A workaround from Stackoverflow can be found here or you can implement your own solution.
Proposed ksqlDB.RestApi.Client APIs:
var contextOptions = new KSqlDbContextOptionsBuilder()
.UseKSqlDb(ksqlDbUrl)
.SetJsonSerializerOptions(c =>
{
c.Converters.Add(new CustomJsonConverter());
}).Options;
and
contextOptions = new KSqlDBContextOptions(ksqlDbUrl)
.SetJsonSerializerOptions(serializerOptions =>
{
serializerOptions.Converters.Add(new CustomJsonConverter());
});
Hi @tomasfabian, Proposed solution looks fine to me. Please integrate proposed solution into ksqlDB.RestApi.Client API, will test it same and share with you the result. Thank you.
Hi @vijaymandave, I released ksqlDb.RestApi.Client -Version 1.4.0 with the above mentioned functionality.
Thank you, too.
Thanks a lot @tomasfabian. A custom JSON converter into KSqlDbProvider option working for me as you suggested.
You are welcome @vijaymandave.
Hi,
I am using below code to read record from Kafka table with nuget ksqlDB.RestApi.Client version 1.3.1.
POCO class
RepeatedField is google protobuf type which refers IEnumerable
C# Insert record code
Issue :In fetched records, items not included of repeated data type.
Please suggest.