You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on semi-abstract formatter to deserialize messages from Kafka. Those are messages that are inherited from the same parent, say AuditEventBase, serialized to JSON string, passed via Kafka, and now I need to deserialize those to their according origin type. Messages contain the field, say EventName that is name of the type and by that name the origin type can be discovered.
I created my own formatter and, basically, it runs through the JSON searching for the field with certain name, that aforementioned EventName, gets the value, finds the Type by the value and then calls JsonSerializer.NonGeneric.Deserialize(eventTypeValue, ref reader);
What I get
I don't control the contracts of those AuditEventBase and they have non-empty constructors, such as:
Like, even the parent abstract class overrides the default constructor. There is the issue in neuecc's repository: neuecc#216 that tells that the object must have empty constructor. The problem is in this case the deserialization goes fine. But if only I remove one of those two autoprops (TestString / TestInt) I get an exception: generated serializer for UploadDocumentInboundErrorEAPAuditEvent does not support deserialize
And it goes red if any of two properties TestString/TestInt are commented and green if both are there. As you can see, they don't even participate in TestAuditEvent, just sit there.
What I expect to get
I understand that the idea of "only empty constructor classes can be deserialized", but maybe either fail fast for every json that is being deserialized to classes without empty constructors or make it work for every case?
The text was updated successfully, but these errors were encountered:
UPD:
After reading the source code I realised the issue was with arguments naming. Would you accept the pull request with changes in readme.md, mentioning how to use objects with constructors with parameters?
What I'm trying to do
I'm working on semi-abstract formatter to deserialize messages from Kafka. Those are messages that are inherited from the same parent, say
AuditEventBase
, serialized to JSON string, passed via Kafka, and now I need to deserialize those to their according origin type. Messages contain the field, sayEventName
that is name of the type and by that name the origin type can be discovered.I created my own formatter and, basically, it runs through the JSON searching for the field with certain name, that aforementioned
EventName
, gets the value, finds theType
by the value and then callsJsonSerializer.NonGeneric.Deserialize(eventTypeValue, ref reader);
What I get
I don't control the contracts of those
AuditEventBase
and they have non-empty constructors, such as:Like, even the parent abstract class overrides the default constructor. There is the issue in neuecc's repository: neuecc#216 that tells that the object must have empty constructor. The problem is in this case the deserialization goes fine. But if only I remove one of those two autoprops (
TestString
/TestInt
) I get an exception:generated serializer for UploadDocumentInboundErrorEAPAuditEvent does not support deserialize
Basically, I have this test
And it goes red if any of two properties
TestString
/TestInt
are commented and green if both are there. As you can see, they don't even participate inTestAuditEvent
, just sit there.What I expect to get
I understand that the idea of "only empty constructor classes can be deserialized", but maybe either fail fast for every json that is being deserialized to classes without empty constructors or make it work for every case?
The text was updated successfully, but these errors were encountered: